Solved QCompleter and navigate with arrows
-
Hi,
I have an Qcompleter on QlineEdit simply, and I want when I key press on down arrow, the completer don't return the first value, but juste navigate into?
It's possible todo this ?thanks
-
I am not 100% sure I get where you want to navigate into, but in any case what you need is probably an event filter installed on the QLineEdit.
For more info also check out the Events Filter section of the Event System page.
-
@cfdev
If you want just open a popup window with appropriate results, trysetCompletionMode(QCompleter::PopupCompletion);
-
Like webbrowser chrome, mozilla,
For example;If I have 5 results in QCompleter, and I want the Second result, I must take the mouse and click on it. I would like keypress down arrow for select the second result and press Enter to validate.
-
QStringList wordList; wordList << "alpha" << "omega" << "omicron" << "zeta"; QLineEdit *lineEdit = new QLineEdit(); QCompleter *completer = new QCompleter(wordList); completer->setCaseSensitivity(Qt::CaseInsensitive); lineEdit->setCompleter(completer); completer->setCompletionMode(QCompleter::PopupCompletion); lineEdit->show();
Is this what you want?
-
Doing like this :
-
@cfdev
It's exactly the same behaviour like from example above. I don't see any difference. -
My problem is on popup, I resfresh the model of QCompleter on textChanged event
like this:void DialogInvoice::on_lineEdit_description_textChanged(const QString &arg1) { QStringList wordList; QString text = arg1; // get data from database m_invoice->getDescriptionList(wordList, 25, text); // removeDuplicates wordList.removeDuplicates(); // setModel m_strList_model->setStringList(wordList); m_completer->setModel(m_strList_model); }
It's work but when I try to select list by the keyboard the popup disappears...
-
Ok, I found the problem it's slot textChanged,
I changed by textEdited and all is ok :)
nice ++