With:
tableView = QTableView()
rows = [0, 1, 2]
tableView.selectRow(0)
or tableView.selectRow(2)
won't work in this situation since selectRow()
selects only single row deselecting all others.
There is selectionModel().select()
method available. But it accepts QSelectionItem
s object as the argument. How do we declare the QSelectionItem
object having the row numbers?
You should set the selection mode.
tableView->setSelectionMode(QAbstractItemView::MultiSelection);