By default, the completion mode is inline (i.e. just selected text, with no alternatives). To get the drop-down list of possible alternatives, do:
combobox.completer().setCompletionMode(QtGui.QCompleter.PopupCompletion)
First line : autocompletion is only anycodings_qcombobox available for an editable combobox.,Second line : sets required behavior for anycodings_qcombobox autocomplete method,Last line : prevents the user to add anycodings_qcombobox items to the list (to better match the anycodings_qcombobox example behavior you provided),To get the same behaviour as in the anycodings_qcombobox example, you will need to change the anycodings_qcombobox completion mode of the completer for the anycodings_qcombobox combobox.
By default, the completion mode is anycodings_qcombobox inline (i.e. just selected text, with no anycodings_qcombobox alternatives). To get the drop-down list anycodings_qcombobox of possible alternatives, do:
combobox.completer().setCompletionMode(QtGui.QCompleter.PopupCompletion)
Start by creating a list of options (names) / suggestions. Thencreate a QCompleter, a completer = QCompleter(names).,PyQt supports autocomplete. If you type in a text box (QLineEdit), it can make suggestions. Those suggestions are recommended from a list.,If you forget the last line, the QCompleter and QLineEdit are not connected, meaning there is no auto completion.,You can add suggestions (you defined earlier) to the list. The suggestions are added with the line:
12
names = ["Apple", "Alps", "Berry", "Cherry"] completer = QCompleter(names)
1
self.lineedit = QLineEdit()
self.lineedit.setCompleter(completer)
12345678910111213141516171819202122