[SOLVED] Find out which items are selected in QTreeView when using ExtendedSelection?
-
wrote on 7 May 2013, 19:22 last edited by
I have a QTreeView where I can select multiple rows by holding down "Ctrl".
To do this, I have used:
@setSelectionMode(QAbstractItemView::ExtendedSelection);@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?
-
wrote on 8 May 2013, 00:19 last edited by
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.
-
wrote on 8 May 2013, 08:11 last edited by
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...
1/3