Is there a signal which is emitted when the user selects a row in QTableView
by mouse (single selection model)?
Asked
Active
Viewed 1.9k times
24

Daniel Fischer
- 181,706
- 17
- 308
- 431

danatel
- 4,844
- 11
- 48
- 62
-
It absolutely has to be the mouse? – balpha Jan 14 '10 at 08:16
1 Answers
21
Each view has a Selection model :
QItemSelectionModel * QAbstractItemView::selectionModel () const
and with the selection model you can retrieve lots of informations, in your case :
QModelIndexList QItemSelectionModel::selectedRows ( int column = 0 ) const
So :
myTableView->selectionModel()->selectedRows();
You can then retrieve this informations through a signal like :
void QItemSelectionModel::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) [signal]
Hope it helps !

Andy M
- 5,945
- 7
- 51
- 96
-
3Alternative way to detect clicking on elements of your table view is using "void QAbstractItemView::clicked ( const QModelIndex & index )" signal – cybevnm Jan 14 '10 at 12:03