Automatically highlight the first row of Qtreewidget?
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