Hi,
I'm trying to create a list of checkbox items that change the status on activation. I can connect the activate signal and everything seems to work, but changes on the screen. Am I missing some steps here?
Here's the list creation:
self.listField = QtGui.QListWidget(self)
muted_categories = qb.settingsCollection['mutedCategories'].split('|')
main_categories = sorted(set(qb.categoryTopNames.values()))
for category in main_categories:
item = QtGui.QListWidgetItem(category, self.listField)
item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
if category in muted_categories:
item.setCheckState(QtCore.Qt.Checked)
else:
item.setCheckState(QtCore.Qt.Unchecked)
self.listField.connect(self.listField, QtCore.SIGNAL('itemActivated(QListWidgetItem*)'), self.doItemChangeState)
and here's the handler:
def doItemChangeState(self, item):
""" invert the state of the activated item """
if item.checkState() == QtCore.Qt.Checked:
item.setCheckState(QtCore.Qt.Unchecked)
else:
item.setCheckState(QtCore.Qt.Checked)
I verified that the handler is fired after clicking - if I put prints there, it will alternate "checked" / "unchecked". What can I do to refresh the checkboxes themselves?
Edit: tried calling update() and emitting the itemChanged signals... no luck so far.