(view, row_indices, command=QItemSelectionModel.ClearAndSelect)
Select several rows in view.

    :param QAbstractItemView view:
    :param row_indices: Integer indices of rows to select.
    :param command: QItemSelectionModel.SelectionFlags
Select several rows in view.
Select several rows in view .
def select_rows(view, row_indices, command=QItemSelectionModel.ClearAndSelect):
    """
    Select several rows in view.

    :param QAbstractItemView view:
    :param row_indices: Integer indices of rows to select.
    :param command: QItemSelectionModel.SelectionFlags
    """
    selmodel = view.selectionModel()
    model = view.model()
    selection = QItemSelection()
    for row in row_indices:
        index = model.index(row, 0)
        selection.select(index, index)
    selmodel.select(selection, command | QItemSelectionModel.Rows)
def select_rows ( view , row_indices , command = QItemSelectionModel . ClearAndSelect ) : selmodel = view . selectionModel ( ) model = view . model ( ) selection = QItemSelection ( ) for row in row_indices : index = model . index ( row , 0 ) selection . select ( index , index ) selmodel . select ( selection , command | QItemSelectionModel . Rows )