[SOLVED] Find out which items are selected in QTreeView when using ExtendedSelection?
I have a QTreeView where I can select multiple rows by holding down "Ctrl".
To do this, I have used:
To find out which item is clicked I used to look at the signal
@clicked( const QModelIndex &)@
However, now that I can have multiple items selected, how can I find out which items are selected, and ignore the ones that are not?
Something like this should work:
QModelIndexList index_list = abstract_view->selectedIndexes();
QModelIndexList is simply QList<QModelIndex> so you can use standard iterators to run the list of items.
You should also have a look at QAbstractItemView::selectionModel() and the QItemSelectionModel class returned by this method.
It gives you more detailed information and possibilities to modifiy the selection...