Is there a method in Qt for a text line with which you can create hints, for example in a search (like in Google, when you start typing, and he already displays hints)?
2 answers
In Qt, the designated functionality is implemented using QCompleter . The data source can be either a regular list of strings or a model.
Any third-party service can also be connected, but for obvious reasons, the implementation of the connection itself is given to the application developer.
An example of using QCompleter from Qt Help:
QStringList wordList; wordList << "alpha" << "omega" << "omicron" << "zeta"; QLineEdit *lineEdit = new QLineEdit(this); QCompleter *completer = new QCompleter(wordList, this); completer->setCaseSensitivity(Qt::CaseInsensitive); lineEdit->setCompleter(completer); As soon as the user of the program begins to enter text into the input field, a list of possible options will appear.
- I didn’t know, thank you with the question’s creator - Roman Novoselov
- @RomanNovoselov, mutually, did not know about gugloapi. - alexis031182
- oneYes there is nothing else - even the name of books or authors, for example Google Books APIs, developers.google.com/books habrahabr.ru/post/243853 - Roman Novoselov
This is not a method, but a separate functionality.
First you must have a "place" from where to get "hints"
Let me explain with an example: For example, you have to "add" the name of a city by typing in a few letters.
As a part of the “hint repositories”, you can use the Google Place API. That is, the user enters several letters, you make a request to the API and the result is obtained (you bring a set of places to the combo box). Again, you can use your own dictionary as a storage, the main thing is to have a method that returns a set of strings (for example, on a regular basis).