diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 0dd85f2d56a..918c2e0b971 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1896,9 +1896,11 @@ bool QWindow::event(QEvent *ev) case QEvent::Close: { Q_D(QWindow); bool wasVisible = isVisible(); - destroy(); - if (wasVisible) - d->maybeQuitOnLastWindowClosed(); + if (ev->isAccepted()) { + destroy(); + if (wasVisible) + d->maybeQuitOnLastWindowClosed(); + } break; } case QEvent::Expose: diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 79f90f2c626..efdfd497a65 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -330,6 +330,7 @@ protected: virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); + // TODO Qt 6 - add closeEvent virtual handler virtual bool event(QEvent *); virtual void keyPressEvent(QKeyEvent *);