Skip to content
Qt 6.11 is out! See what's new in the release blog
  • 0 Votes
    2 Posts
    139 Views
    T
    Because I found the solution in the meantime I reply to my own post. The following code sets the selection as expected: void TElementBorderName::setBorder(const QString& border) { mBorder = border; const QModelIndexList matches = mModel->match(mModel->index(0, 0), Qt::DisplayRole, border, 1, Qt::MatchExactly | Qt::MatchRecursive); if (!matches.isEmpty()) { const QModelIndex modelIdx = matches.first(); // Temporarily set the root to the parent to allow row-based selection mCombo->setRootModelIndex(modelIdx.parent()); mCombo->setCurrentIndex(modelIdx.row()); // Restore the original root to show the full tree mCombo->setRootModelIndex(QModelIndex()); } } A.T.