Hi.
I want to restore a selection in a QTreeWidget object, which I just before cleared (clearSelection()).
My approach is to call this function:
Qt Code:
void QUSongTree::restoreSelection(const QModelIndexList &selectedIndexes) { QItemSelection selection; }To copy to clipboard, switch view to plain text mode
I got "selectedIndexes" from a function with the same name. But those indexes change between clearing and restoring the selection.
Then I did want to get the right QModelIndex after my operation on my own to restore the selection - but how to do this without a rootIndex()?
Why is QTreeWidget::rootIndex() always invalid?
I know the rows of these items which should be selected through QTreeWidget::indexOfTopLevelItem(). How to get the right model indexes to these items?
It is not a wanted solution to call QTreeWidgetItem::setSelected(bool) because that is the status quo in my project here and terribly slow due to heavy signal emitting of itemSelectionChanged()... I did disconnect my 2 functions which use that signal, but it wasn't better.
My operation got a speedup of 10-times with clearing the current selection at first.
Any ideas?
Bookmarks