def createEditor(self, parent, option, index): if not index.isValid(): return QSqlRelationalDelegate.createEditor(self, parent, option, index) if index.column() in self.__read_only: return None elif index.column() in self.__dates: return QDateEdit(QDate.currentDate(), parent) elif index.column() in self.__booleens: editor = QCheckBox("", parent) r = self.checkBoxRect(option, editor) rect = option.rect rect.moveTo(r.x(), r.y()) rect.setWidth(r.width()) rect.setHeight(r.height()) editor.setGeometry(rect) editor.setAutoFillBackground(True) return editor elif index.column() in self.__numbers: editor = QSpinBox(parent) editor.setMinimum(0) editor.setMaximum(100) return editor return QSqlRelationalDelegate.createEditor(self, parent, option, index)