diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2022-05-13 11:01:43 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2022-06-13 09:19:17 +0200 |
commit | e7477e8934ab38722f5589914d08b3f15e870109 (patch) | |
tree | 353a381e2aa714ef077b60ec26f91196741f8f70 /tests/auto/gui | |
parent | e57ab1b454255b5d64b8463cc3ccdb96e7de836e (diff) |
Update window geometry when QWindow::m{in|ax}imumSize is updated
More specifically, if either minimum or maximum size are updated, make
sure that the current window geometry is updated so that it is within
the minimum and maximum sizes.
Previously, these constraints was only respected by the window manager
when the user resized the window.
For widgets this already worked, because a top-level widget will take
care of respecting these constraints if they are changed.
Since QWindow::setMinimumSize and QWindow::setMaximumSize started to
share so many common things, a new function (setMinOrMaxSize_helper())
is added.
Task-number: QTBUG-102771
Change-Id: Ia4b2680dcf865f84a3cf6424187f9a6036b76386
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index dafa69fb96..342e6489ed 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1610,6 +1610,17 @@ void tst_QWindow::sizes() QCOMPARE(minimumHeightSpy.count(), 1); QCOMPARE(maximumWidthSpy.count(), 1); QCOMPARE(maximumHeightSpy.count(), 1); + + // test if min and max limits will change the size + QVERIFY(window.minimumWidth() < 50 && window.maximumWidth() > 80); + QVERIFY(window.minimumHeight() < 50 && window.maximumHeight() > 80); + window.resize(50, 50); + QCOMPARE(window.size(), QSize(50, 50)); + window.setMinimumSize(QSize(60, 60)); + QCOMPARE(window.size(), QSize(60, 60)); + window.resize(80, 80); + window.setMaximumSize(QSize(70, 70)); + QCOMPARE(window.size(), QSize(70, 70)); } class CloseOnCloseEventWindow : public QWindow |