diff options
| author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2026-03-24 17:34:29 +0100 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2026-04-24 02:02:37 +0000 |
| commit | 02b6f7744c0feef74a1b07d986001d48c37fe908 (patch) | |
| tree | e0f89c9cc0f24ddc03c0bade945595a2174a7098 | |
| parent | 6f2cf165ba70e00934d42d924c1487a4285a22d6 (diff) | |
Pass arguments to QMarginsF in the correct order
QQuickPopupPrivate::windowInsets() returns a QMarginsF object.
The constructor used is
constexpr QMarginsF(qreal left, qreal top, qreal right, qreal bottom) noexcept;
The values passed for top and right were swapped. Fix it in this patch.
Add test that verifies that the margins are set in the correct order.
Pick-to: 6.8
Change-Id: I25af57ac5ee6ddd056dda310392f7f9b2633f302
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit b41c6899490135268d27ccfb0cf552f1379387e8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| -rw-r--r-- | src/quicktemplates/qquickpopup.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/quicktemplates/qquickpopup.cpp b/src/quicktemplates/qquickpopup.cpp index 69bc1bb440..30ab3db1a7 100644 --- a/src/quicktemplates/qquickpopup.cpp +++ b/src/quicktemplates/qquickpopup.cpp @@ -698,8 +698,8 @@ QMarginsF QQuickPopupPrivate::windowInsets() const return { q->leftInset() < 0 ? -q->leftInset() : 0, - q->rightInset() < 0 ? -q->rightInset() : 0, q->topInset() < 0 ? -q->topInset() : 0, + q->rightInset() < 0 ? -q->rightInset() : 0, q->bottomInset() < 0 ? -q->bottomInset() : 0 }; } diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp index dca04a0b00..49ea1a5b13 100644 --- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp @@ -161,6 +161,7 @@ private slots: void blockEventsBehindModal_data(); void blockEventsBehindModal(); void spacingAndInsetsAreRevaluatedWhenChanged(); + void windowInsetsOrder(); private: QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice()); @@ -3929,6 +3930,37 @@ void tst_QQuickPopup::spacingAndInsetsAreRevaluatedWhenChanged() QCOMPARE(popup->bottomInset(), initialBottomInset + offset); } +void tst_QQuickPopup::windowInsetsOrder() +{ + if (!arePopupWindowsSupported()) + QSKIP("The platform doesn't support popup windows. Skipping test."); + + QQuickApplicationHelper helper(this, "simplepopup.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + auto *popup = window->property("popup").value<QQuickPopup *>(); + QVERIFY(popup); + + popup->setPopupType(QQuickPopup::Window); + // Use distinct values per side so any swap is immediately visible. + popup->setLeftInset(-5); + popup->setTopInset(-10); + popup->setRightInset(-15); + popup->setBottomInset(-20); + + popup->open(); + TRY_VERIFY_POPUP_OPENED(popup); + + const QMarginsF insets = QQuickPopupPrivate::get(popup)->windowInsets(); + QCOMPARE(insets.left(), 5); + QCOMPARE(insets.top(), 10); + QCOMPARE(insets.right(), 15); + QCOMPARE(insets.bottom(), 20); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" |
