def setModelData(self, editor, model, index): if index.column() == SIVA: model.setData(index, QVariant(editor.text().replace(',', '.'))) elif index.column() == SIMP: model.setData(index, QVariant(editor.text().replace(',', '.'))) else: QSqlRelationalDelegate.setModelData(self, editor, model, index)
def setModelData(self, editor, model, index): if index.column() == DATAINS: model.setData(index, QVariant(editor.date())) self.lastData = editor.date() elif index.column() == IMP: model.setData(index, QVariant(editor.text().replace(',', '.'))) else: QSqlRelationalDelegate.setModelData(self, editor, model, index)
def setEditorData(self, editor, index): if index.column() == DATAINS: editor.setDisplayFormat(DATEFORMAT) if not self.lastData: self.lastData = QDate.currentDate() editor.setDate(self.lastData) else: QSqlRelationalDelegate.setEditorData(self, editor, index)
def createEditor(self, parent, option, index): if index.column() == CPIVA: editor = QLineEdit(parent) validator = QRegExpValidator(QRegExp(r"\d{11}"), self) editor.setValidator(validator) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) return editor else: return QSqlRelationalDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): if index.column() == SQT: editor = MyQLineEdit(parent) validator = QIntValidator(self) editor.setValidator(validator) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.connect(editor, SIGNAL("keyDownPressEvent()"), self.gestEvt) return editor elif index.column() == SDESC: editor = MyQLineEdit(parent) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.connect(editor, SIGNAL("keyDownPressEvent()"), self.gestEvt) return editor return QSqlRelationalDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): if index.column() == DATAINS: editor = QDateEdit(parent) editor.setCalendarPopup(True) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) return editor elif index.column() == QT: editor = QLineEdit(parent) validator = QIntValidator(self) editor.setValidator(validator) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) return editor elif index.column() == IMP: editor = QLineEdit(parent) validator = QDoubleValidator(self) validator.setDecimals(3) editor.setValidator(validator) editor.setAlignment(Qt.AlignRight|Qt.AlignVCenter) return editor else: return QSqlRelationalDelegate.createEditor(self, parent, option, index)