Reputation: 1159
It's not showing any popup or error. It silently doing nothing.
QStringList dictionary;
dictionary << "exampleOne" << "Two" << "blah" << "hello";
dictionary.sort();
QCompleter * completer = new QCompleter(dictionary,ui->inRawText);
completer->setModel(new QStringListModel(dictionary, completer));
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setWidget(ui->inRawText);
inRawText is instance of QTextEdit class.
EDIT: Signals (activated and highlighted) are not emited.
EDIT: Popup is shown only if I call complete() slot. It's stupid, I must reimplement QTextEdit class and it's keyPressEvent handler ... damned QT...
Upvotes: 1
Views: 1439
Reputation: 4350
Making a QTextEdit
the parent of a QCompleter
only affects the ownership hierarchy, it does not mean that the QCompleter
must start processing text for the QTextEdit
.
In fact, QCompleter
does not function as an autocompleter for QTextEdit
, it only works for QLineEdit
and QComboBox
and you use the setCompleter()
function of those two classes to start the autocompletion.
Read the documentation of QCompleter
for more information.
Upvotes: 0