Hi All,
I'm using QTreeView. I need to preserve currently selected item while some items are added or removed to/from the tree (model). Also: can I force QTreeView to never lose selection event if the focus changes to other windows?
Thanks
Hi All,
I'm using QTreeView. I need to preserve currently selected item while some items are added or removed to/from the tree (model). Also: can I force QTreeView to never lose selection event if the focus changes to other windows?
Thanks
Just found the answer..
QItemSelectionModel* selModel = selectionModel();
//save current selection
QModelIndex selected = selModel->currentIndex();
//my code that adds an item to the tree
// _model->addValue(sysPlugin, newValue);
expandAll();
//restore original selection
selModel->setCurrentIndex(selected, QItemSelectionModel::SelectCurrent);
Bookmarks