QTableView - what signal is sent when user selects a row by clicking to it?

16,314

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 !

Share:
16,314
danatel
Author by

danatel

Updated on June 15, 2022

Comments

  • danatel
    danatel about 2 years

    Is there a signal which is emitted when the user selects a row in QTableView by mouse (single selection model)?

  • cybevnm
    cybevnm over 14 years
    Alternative way to detect clicking on elements of your table view is using "void QAbstractItemView::clicked ( const QModelIndex & index )" signal