[Qt-interest] QDialog::closeEvent() is called only when a modal dialog is closed by clicking the "X" button
Zeljko
zeljko at holobit.net
Tue Jun 28 16:08:07 CEST 2011
Constantin Makshin wrote:
> Hello!
>
> I want to save some modal dialog's parameters when it's closed and restore
> them when it's created/opened again. The obvious way is to save parameters
> inside the closeEvent() function and restore inside the constructor. This
> approach works for QMainWindow derivatives but has some weird behavior for
> modal dialogs — closeEvent() is called only when the dialog is closed by
> clicking the "X" button or choosing corresponding window context menu item. If
> the user presses "OK" or "Cancel" button (or takes some other action that's
> connected to accept() or reject()), closeEvent() is not called, making the
> dialog-parameter-saving idea mostly useless.
>
> Is this a bug or intended behavior?
I guess it's bug, since closeEvent() should be passed before real closing ...and
there you can stop it. eg. "Do you really want to close this window (no matter
that's modal window or dialog or whatever" ...especially if that triggers on
close button ("X").
zeljko
More information about the Qt-interest-old
mailing list