'How to set combobox data from a model in pyqt
Generally I set combobox data as follows:
cbo.addItem("xyz",QVariant(1)) -- xyz is value shown in the cbo and 1 is its data
I am setting checkable cbo value from a pyqt model as follows:
model = QtGui.QStandardItemModel(len(cases_array), 1)
for index, case in enumerate(cases_array):
item = QtGui.QStandardItem(case[1])
item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
item.setData(QtCore.Qt.Unchecked, QtCore.Qt.CheckStateRole)
model.setItem(index, 0, item)
cbo.setModel(model)
It works great. But when I do cbo.itemData(0).toPyObject() I dont get any value.
How can I set cbo data value.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
