pyqt_dev2
9th February 2015, 09:55
Hi guys,
The following code works but doesn't do in full what exactly is needed:
nameList = ('John','Tom','Henry','Michelle','Ashish','Jo-Huang', ...)
colorNameList = ('Michelle','Jennifer','Claudia','JimSung', ...)
callBackObj.NameComboBox.clear()
callBackObj.NameComboBox.addItem(QString('Account Names'))
model = callBackObj.NameComboBox.model()
for name in nameList:
item = PyQt4.QtGui.QStandardItem(str(account))
if name in colorNameList:
item.setBackground(PyQt4.QtGui.QColor('red'))
model.appedRow(item)
Now whenever I expand and view the dropdown, the names in colorNameList appear in red background. So far so good. However when I select one of these red-background names they do not show as red-background when left selected.
Any ideas how I can ensure that on selection red items appear red and non-red appears non-red.
Many thanks!
Rahul
The following code works but doesn't do in full what exactly is needed:
nameList = ('John','Tom','Henry','Michelle','Ashish','Jo-Huang', ...)
colorNameList = ('Michelle','Jennifer','Claudia','JimSung', ...)
callBackObj.NameComboBox.clear()
callBackObj.NameComboBox.addItem(QString('Account Names'))
model = callBackObj.NameComboBox.model()
for name in nameList:
item = PyQt4.QtGui.QStandardItem(str(account))
if name in colorNameList:
item.setBackground(PyQt4.QtGui.QColor('red'))
model.appedRow(item)
Now whenever I expand and view the dropdown, the names in colorNameList appear in red background. So far so good. However when I select one of these red-background names they do not show as red-background when left selected.
Any ideas how I can ensure that on selection red items appear red and non-red appears non-red.
Many thanks!
Rahul