Hi,
I have a QTreeView derived from QAbstractItemModel.
I want to make the selection to the topmost node(root node) of the tree when the UI launches.
Below is my code, but no selection happening.
QModelIndex rootIndex = TreeView->rootIndex();
QModelIndex rootChildIndex = TreeModel->index(0, 0, rootIndex);
if (rootChildIndex.isValid())
{
TreeView->selectionModel()->select(rootChildIndex , QItemSelectionModel::Select);
}
Bookmarks