tags:

views:

326

answers:

2

Is there a signal which is emmited when user selects a row in QTableView by mouse (sigle selection model)?

+1  A: 

Is it acceptable to listen to activated() or clicked() signals, and retrieve the row from the QModelIndex object they provide?

David Parunakian
+1  A: 

Hey,

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
Thanks, it works.
danatel
vnm