Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QDialog::closeEvent not fired by Esc-Key
Andy314 last edited by Andy314
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
done()with appropriate error codes.
Neither of these
close()the window in the closeEvent sense, they merely
Pressing the "X" button calls
close()generates a close event.
As stated in the docs you should implement
done()to do any custom closing behavior.
closeEventshould only be used to store the dialog position if needed.