Solved abandoning/reverting changes in a QDialog
-
Hi all -
I'm writing an app that uses a QDialog to edit a row in a QAbstractItemModel. I just realized that if I make changes to some fields, then hit cancel, my changes are retained. This is probably a side effect of working directly in the model, but I can't have this. Is there a standard way of handling this?
-
Hi,
You can use QDataWidgetMapper with the submitPolicy set to
ManualSubmit
. That way you fully control when the changes are sent to your model. -
Oh, that's a thing of beauty.
QDataWidgetMapper *m_mapper; ... m_mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); ... if (buttonPushed == QMessageBox::Save) { // we specified manual submit policy in c'tor, // so we need to call submit() here. m_mapper->submit();
Thanks, SGaist.