ekh*_*oro 41
是的,有QComboBox.findText,它将返回匹配项的索引(如果没有,则返回-1).默认情况下,搜索会进行精确的区分大小写匹配,但您可以通过传递一些匹配标志作为第二个参数来调整行为.例如,要进行不区分大小写的匹配:
index = combo.findText(text, QtCore.Qt.MatchFixedString)
if index >= 0:
combo.setCurrentIndex(index)
Run Code Online (Sandbox Code Playgroud)
还有一个等效的findData方法,它与项目的数据相匹配.