def METHOD_NAME(self, rows):
    item = self.listbox.item
    for row in range(self.listbox.count()):
        if row in rows:
            item(row).setCheckState(Qt.CheckState.Checked)
        else:
            item(row).setCheckState(Qt.CheckState.Unchecked)