Fastest way to select qtreeview items programatically...
Unsolved
General and Desktop
-
Hey
I sweat I was asking for it before but I cant find topic... in any case... is this the fastest way ?
QItemSelection sel; QVector<QItemSelection>selList(items.size()); for (int x = 0; x < items.size(); ++x) { selList[x]= QItemSelection(items[x], items[x]); } for (int x = 0; x < items.size(); ++x) { sel.merge(selList[x], QItemSelectionModel::Select); } mSelectionRangeOld = selectionModel()->selection(); if (cSel) { selectionModel()->clearSelection(); } if (extend) { selectionModel()->select(sel, QItemSelectionModel::Select | QItemSelectionModel::Rows); } else { selectionModel()->select(sel, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); }
Can any part of it be done in thread? I'm worried with 20-30k rows & 10 columns could be slow... like very slow...
TIA
-
Hi,
Out of curiosity, why do you need to select that much elements programmatically ?
-
Never tried selecting 50K items before. But if they happen in a single method call/forloop, it'll likely be much faster if you:
- Stop UI updates by calling
qtreeview->setUpdatesEnabled(false)
at the beginning andqtreeview->setUpdatesEnabled(true)
at the end. - Stop item related signals from being generated by calling
qtreeview->blockSignals(true)
at the beginning andqtreeview->blockSignals(false)
at the end.
Once this is done, then the only cpu usage would be qtreeview model being updated and final UI update at the end.
- Stop UI updates by calling
-
Why would someone see 50k meshes in a tree view? What should the user do with this information...