Use Qt::WindowNoState for child windows/widgets shown via show()
The Qt::WindowState enum is documented to specify the current state of top-level windows, and does not make sense for child windows. It's up to the client code to ensure any sizing of child windows/widgets, e.g. via layouts. Many of our QPA backends bail out on QPlatformWindow::setWindowState() for a child window. Ideally we would do this at a higher level, in QWindow, but that's a bigger task, and the semantics of what happens when a window is moved from being top level to child or back are not fully clear. As a first step, we ensure that the default window state when showing the window via show() is Qt::WindowNoState. Unfortunately, the QPlatformIntegration::defaultWindowState() API only takes into account the window flags, which sadly do not have a way to reflect whether the window is a child window or not (Qt::SubWindow is not a child window, see QTBUG-115729). We don't want to pass a QWindow to this API, as it would mean QWidget would need to create a window when requesting the default window state. Instead we hard-code the opt-out for child windows/widgets. [ChangeLog][Gui/Widgets] Child windows and widgets are now always shown in their normal state by show(). Change-Id: Ie8caf2df2d854194b9985c9427a9eac1312aba65 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 3472aa6e28469ffd23cfa24e3933541f295e9e1d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
81ca04d1b1
commit
5419df55f3
@ -2231,20 +2231,26 @@ QObject *QWindow::focusObject() const
|
||||
/*!
|
||||
Shows the window.
|
||||
|
||||
This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),
|
||||
For child windows, this is equivalent to calling showNormal().
|
||||
Otherwise, it is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),
|
||||
depending on the platform's default behavior for the window type and flags.
|
||||
|
||||
\sa showFullScreen(), showMaximized(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()
|
||||
*/
|
||||
void QWindow::show()
|
||||
{
|
||||
Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(d_func()->windowFlags);
|
||||
if (defaultState == Qt::WindowFullScreen)
|
||||
showFullScreen();
|
||||
else if (defaultState == Qt::WindowMaximized)
|
||||
showMaximized();
|
||||
else
|
||||
if (parent()) {
|
||||
showNormal();
|
||||
} else {
|
||||
const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
|
||||
Qt::WindowState defaultState = platformIntegration->defaultWindowState(d_func()->windowFlags);
|
||||
if (defaultState == Qt::WindowFullScreen)
|
||||
showFullScreen();
|
||||
else if (defaultState == Qt::WindowMaximized)
|
||||
showMaximized();
|
||||
else
|
||||
showNormal();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -7954,21 +7954,29 @@ void QWidget::setUpdatesEnabled(bool enable)
|
||||
/*!
|
||||
Shows the widget and its child widgets.
|
||||
|
||||
This is equivalent to calling showFullScreen(), showMaximized(), or setVisible(true),
|
||||
depending on the platform's default behavior for the window flags.
|
||||
For child windows, this is equivalent to calling setVisible(true).
|
||||
Otherwise, it is equivalent to calling showFullScreen(), showMaximized(),
|
||||
or setVisible(true), depending on the platform's default behavior for the window flags.
|
||||
|
||||
\sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
|
||||
\sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
|
||||
showNormal(), isVisible(), windowFlags()
|
||||
*/
|
||||
void QWidget::show()
|
||||
{
|
||||
Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(data->window_flags);
|
||||
if (defaultState == Qt::WindowFullScreen)
|
||||
showFullScreen();
|
||||
else if (defaultState == Qt::WindowMaximized)
|
||||
showMaximized();
|
||||
else
|
||||
setVisible(true); // Don't call showNormal() as not to clobber Qt::Window(Max/Min)imized
|
||||
// Note: We don't call showNormal() as not to clobber Qt::Window(Max/Min)imized
|
||||
|
||||
if (!isWindow()) {
|
||||
setVisible(true);
|
||||
} else {
|
||||
const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
|
||||
Qt::WindowState defaultState = platformIntegration->defaultWindowState(data->window_flags);
|
||||
if (defaultState == Qt::WindowFullScreen)
|
||||
showFullScreen();
|
||||
else if (defaultState == Qt::WindowMaximized)
|
||||
showMaximized();
|
||||
else
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
|
Loading…
x
Reference in New Issue
Block a user