You are overriding the data
method of QStandardItemModel
but not implementing every role that the old data
method handled. You can either implement if/elif
statements for all roles, or my preferred solution, hand off those you don't want to deal with yourself to the original method.
Thus I would change your data
method to read:
def data(self , index , role):
if role == Qt.ToolTipRole:
return self.d
if role == Qt.DisplayRole:
return self.d.text()
return QStandardItemModel.data(self, index, role)
Checkboxes now show up when I make this change to your example.