How to code a drop-down selection box with auto-completer in Qt5 (pyqt5)

北战南征 提交于 2019-12-31 05:09:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!