lundi 5 septembre 2016

Partially check QListWidget item by mouse click (tristate)

I need some items in my list to have 3 states. So i add the following code:

item = QtGui.QListWidgetItem("Hello there")
item.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsUserCheckable |
    QtCore.Qt.ItemIsTristate)
item.setCheckState(QtCore.Qt.PartiallyChecked)

An item is successfully set to partially checked state on its creation, but further mouse clicks switch it between checked/unchecked states.




Aucun commentaire:

Enregistrer un commentaire