Don't destroy the window if the QCloseEvent wasn't accepted
It's possible to override event() to receive the QCloseEvent and do event->ignore() to prevent the window from closing. Task-number: QTBUG-31019 Change-Id: I9abed47fca02a002b78727f98d678a824854adfc Reviewed-by: Samuel Rødal <samuel.rodal@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
1b91379323
commit
df93d356df
@ -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:
|
||||
|
@ -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 *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user