当尝试使用PySide在Qt QComboBox上使用addItem时,我收到以下错误:
AttributeError:'PySide.QtGui.QComboBox'对象没有属性'setCurrentText'
如果addItem方法导致错误,如何使用ComboBox?
答案 0 :(得分:0)
我不知道导致错误的原因,但我可以通过使用显式模型来使用QComboBox。
伪码:
model = QStandardItemModel(comboBox)
item1 = QStandardItem( "item1" )
item2 = QStandardItem( "item2" )
model.appendRow(item1)
model.appendRow(item2)
comboBox.setModel(model)