From 84156b138e196624c3e0effe313105b632f5ef85 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 23 Jan 2023 15:51:21 +0100 Subject: [PATCH] workaround for a Qt 6.5 regression ( see https://bugreports.qt.io/browse/QTBUG-110493 ) --- src/controls/QskWindow.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/controls/QskWindow.cpp b/src/controls/QskWindow.cpp index e63cd663..2bbc11f8 100644 --- a/src/controls/QskWindow.cpp +++ b/src/controls/QskWindow.cpp @@ -143,6 +143,7 @@ class QskWindowPrivate : public QQuickWindowPrivate , explicitLocale( false ) , deleteOnClose( false ) , autoLayoutChildren( true ) + , showedOnce( false ) { } @@ -163,6 +164,7 @@ class QskWindowPrivate : public QQuickWindowPrivate bool explicitLocale : 1; bool deleteOnClose : 1; bool autoLayoutChildren : 1; + bool showedOnce : 1; }; QskWindow::QskWindow( QWindow* parent ) @@ -303,15 +305,33 @@ bool QskWindow::event( QEvent* event ) { case QEvent::Show: { - if ( size().isEmpty() ) + if ( !d->showedOnce ) { - QSize sz = sizeConstraint(); - if ( !sz.isEmpty() ) - { - sz = sz.expandedTo( minimumSize() ); - sz = sz.boundedTo( maximumSize() ); + d->showedOnce = true; - resize( sz ); + /* + When a window has a platform window its size is taken + from the platform window - otherwise from d->geometry. + A top level window that has not been shown does not have + a platform window yet and therefore any size set before calling + QWindow::show() is stored there. + + Starting with Qt 6.5 an initial default size is set to the platform + window ( at least QXcbWindow ) before the Show event is sent + and we can't rely on QWindow::size() anymore. But even if d->geometry + is not used anymore we can initialize depending on it. + */ + + if ( d->geometry.size().isEmpty() ) + { + QSize sz = sizeConstraint(); + if ( !sz.isEmpty() ) + { + sz = sz.expandedTo( minimumSize() ); + sz = sz.boundedTo( maximumSize() ); + + resize( sz ); + } } }