Qt model/view framework selection system - store/restore selections
Solved
General and Desktop
-
Hey
I'm trying to wrap my head around selections in qt. I'd like to store my selection & perform some action(like renaming selected items) and then restore it.
I know I can get selectedIndexes(), but how can I get QItemSelection/QItemSelectionRange object instead? Or how can I convert my selectedIndexes() to QItemSelection/Range ?
I have 20k items and selecting them/reselecting takes quite a bit of time.
Say if I try to re-select items from selectedIndexes()
auto selectedItems = selectedIndexes(); for(auto&itm:selectedItems ){ do stuff selectionModel()->select(itm, QItemSelectionModel::Select | QItemSelectionModel::Rows); }
This can take minutes... from debug that function is marked as 90% time
I also tried using this:
... QItemSelection sel = selectionModel()->selection(); for(auto&itm:selectedIndexes()){ do stuff } selectionModel()->select(sel,QItemSelectionModel::Select | QItemSelectionModel::Rows); ...
But this did not do anything. It does not re-select the items.
I run my selection function after QTreeView::mouseReleaseEvent(event);
Where am I hitting the wall here?