[SOLVED] QDialog::closeEvent not fired by Esc-Key
-
wrote on 11 Aug 2015, 18:09 last edited by Andy314
Hello !
I have subclassed the QDialog and need a preprocessing before a Window closes. It is a modal dialog. I found out that the QDialog::close() and the click on the window X Button fires the closeEvent.But pessing the Esc-Key does not fire the event.
Why that ?
-
Hitting Esc is equivalent to calling
reject()
.
accept()
andreject()
calldone()
with appropriate error codes.
Neither of theseclose()
the window in the closeEvent sense, they merelyhide()
it.Pressing the "X" button calls
close()
. Callingclose()
generates a close event.As stated in the docs you should implement
accept()
,reject()
ordone()
to do any custom closing behavior.closeEvent
should only be used to store the dialog position if needed.
1/2