wasert
26th October 2009, 14:43
Hello,
I am using a custom delegate to provide a QDialog window as an editor to update my entire model at once.
The dialog is displayed properly and the initial editor data is being setup correctly as well.
The model data is saved fine when I click the accept button. However, when I change the values in the editor and click the cancel button, which is connected to the dialogs's reject() signal, the model data is updated too.(that is, the setModelData method of my custom delegate is called)
Here is the method:
def setModelData(self, editor, model, index):
row = index.row()
serial = editor.serialLineEdit.text().trimmed()
barcode = editor.barcodeLineEdit.text().trimmed()
barcode = None if not barcode else barcode
responsable = editor.responsableComboBox.itemData(
editor.responsableComboBox.currentIndex()).toInt()[0]
agregado = editor.fechaAgregadoDateEdit.date()
model.setData(model.index(row, pcols['SERIAL']), QVariant(serial))
model.setData(model.index(row, pcols['BARCODE']), QVariant(barcode))
model.setData(model.index(row, pcols['RESPONSABLE']),
QVariant(responsable))
model.setData(model.index(row, pcols['FECHA_AGREGADO']),
QVariant(agregado))
model.submitAll()
I have set the edit strategy to manual submit by calling:
model.setEditStrategy(model.OnManualSubmit)
I really have no idea of how to fix this. Any help is greatly appreciated.
I am using a custom delegate to provide a QDialog window as an editor to update my entire model at once.
The dialog is displayed properly and the initial editor data is being setup correctly as well.
The model data is saved fine when I click the accept button. However, when I change the values in the editor and click the cancel button, which is connected to the dialogs's reject() signal, the model data is updated too.(that is, the setModelData method of my custom delegate is called)
Here is the method:
def setModelData(self, editor, model, index):
row = index.row()
serial = editor.serialLineEdit.text().trimmed()
barcode = editor.barcodeLineEdit.text().trimmed()
barcode = None if not barcode else barcode
responsable = editor.responsableComboBox.itemData(
editor.responsableComboBox.currentIndex()).toInt()[0]
agregado = editor.fechaAgregadoDateEdit.date()
model.setData(model.index(row, pcols['SERIAL']), QVariant(serial))
model.setData(model.index(row, pcols['BARCODE']), QVariant(barcode))
model.setData(model.index(row, pcols['RESPONSABLE']),
QVariant(responsable))
model.setData(model.index(row, pcols['FECHA_AGREGADO']),
QVariant(agregado))
model.submitAll()
I have set the edit strategy to manual submit by calling:
model.setEditStrategy(model.OnManualSubmit)
I really have no idea of how to fix this. Any help is greatly appreciated.