I'm using a QTreeView
with a custom QStyledItemDelegate
to display various parameter items. I want all of the items to have a check indicator, however some of the Checkboxes should be disabled (but still visible and set checked!).
Here's the Delegate code:
class MyDelegate(QtWidgets.QStyledItemDelegate):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def initStyleOption(self, option, index):
super().initStyleOption(option, index)
option.features |= QtWidgets.QStyleOptionViewItem.HasCheckIndicator
if index.data(MyItem.ROLE_OPTIONAL):
#Disable check indicator here!
Do I have to tamper with MyDelegate.paint()
to make this work?