I just have to stop answering to all those flames... But what can I say, I do love them...
Use QCompleter::currentCompletion() to find a path in the original model and then use QAbstractItemModel::match() to find the proper index in the model.
A possible implementation:
QStringList path
= completer
->currentCompletion
().
split(".");
while(!path.isEmpty()){
sourceIndex = model->match(model->index(0,0, sourceIndex), Qt::DisplayRole, path.first(), 1).first();
path.removeFirst();
}
treeView->scrollTo(index);
QStringList path = completer->currentCompletion().split(".");
const QAbstractItemModel *model = treeView->model();
QModelIndex sourceIndex;
while(!path.isEmpty()){
sourceIndex = model->match(model->index(0,0, sourceIndex), Qt::DisplayRole, path.first(), 1).first();
path.removeFirst();
}
treeView->selectionModel()->select(sourceIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
treeView->scrollTo(index);
To copy to clipboard, switch view to plain text mode
Bookmarks