Hey,
I have a simple model with two columns, which I hand to a QCompleter and attach to a QLineEdit.
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionRole(MyModel::DisplayRole);
completer->setCompletionColumn(0);
input->setCompleter(completer);
completer = new QCompleter(model, this);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionRole(MyModel::DisplayRole);
completer->setCompletionColumn(0);
input = new QLineEdit(this);
input->setCompleter(completer);
To copy to clipboard, switch view to plain text mode
This works well, but now I want the completions/suggestions shown by the completer to display not as "<column0>" but rather as "<column0> : <column1>".
I tried to introduce a custom DisplayRole (Qt::UserRole +1) in my model that always returns "<column0> : <column1>". Turns out this is not for the suggestions, but only for the text set into the linedit AFTER a completion-suggestion is accepted by the user! The suggestions
themselves are still only "<column0>"!
Next thing I tried is to introduce a fake third column in the model that returns the desired format, but is not actually part of the model. This outright doesnt work though.
How do I accomplish the desired behavior?
Bookmarks