Search code examples
qtqt4

Autocomplete textbox in qt?


I am new to QT, how to implement autocomplete textbox in qt or is there already solution for that ? I have vector of words. Can somebody give me advice how to do this ?


Solution

  • Take a look at QCompleter.

    The QCompleter class provides completions based on an item model.

    You can use QCompleter to provide auto completions in any Qt widget, such as QLineEdit and QComboBox. When the user starts typing a word, QCompleter suggests possible ways of completing the word, based on a word list. The word list is provided as a QAbstractItemModel. (For simple applications, where the word list is static, you can pass a QStringList to QCompleter's constructor.)