Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Automatically highlight the first row of Qtreewidget?
marlenet15 last edited by
I have a tree on my application and I would like it so that the first row is highlighted automatically. However, I do not want everything part of that row to be highlighted. For example:
I would only like for fruit to be highlighted in the beginning. I have the following
QTreeWidget *treeWidget = new QTreeWidget; QAbstractItemModel *model = treeWidget->model(); QItemSelectionModel *selectionModel = new QItemSelectionModel(model); QModelIndex index = model->index(0,0); selectionModel->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); treeWidget->setSelectionModel(selectionModel);
However, nothing happens.
You are looking for QTreeWidget::setCurrentItem