PDA

View Full Version : QStyledItemDelegate custom Editor--How to cancel edits



davethomaspilot
11th February 2014, 13:43
I have column specific custom editors implemented using a class derived from QStyledItemDelegate. Most get popuated based on the current item's value and some with other items in the same row (QSqlTableModel).


It works, but I haven't figured out how to NOT apply changes done in the editor. When the dialog is closed, something initiates a call to setModelData(). I'd like that to avoid that call if the dialog's cancel button is pushed instead of the OK.

I could save something in the editor itself that tells my implementation of setModelData NOT to call setData, but I think there's probably something I should implement to take control of what signal does or does not get emitted when the user pushes "OK" versus "Cancel" in the custom editor.

Thanks,

Dave Thomas