class FlagDelegate (QtWidgets.QStyledItemDelegate): def createEditor (self, parent, options, index): editor = QtWidgets.QCheckBox(parent) return editor def setEditorData (self, editor, index): CHval = int(index.model().data(index, QtCore.Qt.EditRole)) if CHval == 0: editor.setCheckState (QtCore.Qt.Unchecked) else: editor.setCheckState (QtCore.Qt.Checked) def updateEditorGeometry (self, editor, options, index): editor.setGeometry (options.rect) def setModelData (self, editor, model, index): UNval = editor.checkState () if UNval == QtCore.Qt.Unchecked: modelVal = 0 else: modelVal = 1 model.setData (index, modelVal, QtCore.Qt.EditRole);
при выполнении строки кода
tv.setItemDelegateForColumn (3, FlagDelegate())
Что не так с делегатом или может в таблице?