问题
A GUI I am amending must show a drop-down read-only list of text lines (a QComboBox), in which the user will choose one line.
As there may be several dozen items in this list, I would like to incorporate the ability for the operator to type a string while focus is on the drop-down and have it auto-position at the first element containing that string (not necessarily a leading sub-string).
It seems impossible to implement anything like this using a QComboBox with a QCompleter because as the text is non-editable the QCompleter is disabled.
The design of Qt5 seems to assume that "auto-complete" must be to add or amend text, and makes no sense otherwise. But I wish to use it, or an equivalent, solely to search for or locate strings within read-only text.
来源:https://stackoverflow.com/questions/54324000/how-to-code-a-drop-down-selection-box-with-auto-completer-in-qt5-pyqt5