My code:
if (!ix.isValid()) return;
qDebug() << "name1" << ix.data();
tree->selectionModel()->clear();
tree->setExpanded(ix.parent(), true);
tree->scrollTo(ix);
}
void TreeModel::selectIndex(QModelIndex ix) {
if (!ix.isValid()) return;
qDebug() << "name1" << ix.data();
tree->selectionModel()->clear();
tree->setExpanded(ix.parent(), true);
tree->selectionModel()->setCurrentIndex(ix, QItemSelectionModel::SelectCurrent);
tree->scrollTo(ix);
}
To copy to clipboard, switch view to plain text mode
This snippet runs ok after deleting/inserting nodes. But when I try to select the remembered node from previous session in QMainWindow::showEvent the result is:
The program has unexpectedly finished.
C:\Home\develop\qt\arm\designer\Designer exited with code -1073741819
name1 QVariant(QString, "Highlight elements")
The program has unexpectedly finished.
C:\Home\develop\qt\arm\designer\Designer exited with code -1073741819
To copy to clipboard, switch view to plain text mode
without
tree->selectionModel()->setCurrentIndex(ix, QItemSelectionModel::SelectCurrent);
To copy to clipboard, switch view to plain text mode
works well, but I do need to select this item.
Thank you very much in advance!
Bookmarks