from PyQt5 import QtWidgets
from itertools import product
app = QtWidgets.QApplication([])
# wordlist for testing
wordlist = [''.join(combo) for combo in product('abc', repeat = 4)]
combo = QtWidgets.QComboBox()
combo.addItems(wordlist)
# completers only work for editable combo boxes. QComboBox.NoInsert prevents insertion of the search text
combo.setEditable(True)
combo.setInsertPolicy(QtWidgets.QComboBox.NoInsert)
# change completion mode of the default completer from InlineCompletion to PopupCompletion
combo.completer().setCompletionMode(QtWidgets.QCompleter.PopupCompletion)
combo.show()
app.exec()
1条答案
按热度按时间brccelvz1#
您可以使用
QCompleter
来完成此操作。对于可编辑的QComboBox
,将自动创建QCompleter
。此完成符执行不区分大小写的内联完成,但您可以根据需要进行调整,例如