You need to create a descendant of QItemSelectionModel and reimplement select
.
virtual void select(const QModelIndex & index, QItemSelectionModel::SelectionFlags command)
virtual void select(const QItemSelection & selection, QItemSelectionModel::SelectionFlags command)
When reimplementing select
you can call QItemSelectionModel::select
with different arguments to achieve the needed result.
Then assign an instance of the selection model to QTableWidget
with setItemSelectionModel
.