aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDheerendra Purohit <dheerendra@pthinks.com>2025-07-30 09:44:59 +0530
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2025-09-09 13:41:49 +0000
commitaefa1e6163d5fcb5da5dfa24568b21eec571df72 (patch)
treeec7e795e24ac5ceb52e2d473f5d05112d5894c6d
parentee62b5fea3058746a909fff6dafb01a59094e78b (diff)
Fix Popup spacing and insets not supporting bindings
Connect spacing and inset change signals from the internal popupItem to the Popup,ensuring that QML bindings and UI updates reflect property changes. Pick-to: 6.8 Fixes: QTBUG-135249 Change-Id: Iab92430406e43942c2818a3f62976ccd2fca025d Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> (cherry picked from commit 8ac989432063884b686af722b3ac8dd81b82c522) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit fc173235b36e72756bd13dca3916c052f217f2e9)
-rw-r--r--src/quicktemplates/qquickpopup.cpp5
-rw-r--r--tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp51
2 files changed, 56 insertions, 0 deletions
diff --git a/src/quicktemplates/qquickpopup.cpp b/src/quicktemplates/qquickpopup.cpp
index 0a8ae354c5..e16fb53b68 100644
--- a/src/quicktemplates/qquickpopup.cpp
+++ b/src/quicktemplates/qquickpopup.cpp
@@ -511,6 +511,11 @@ void QQuickPopupPrivate::init()
QObject::connect(popupItem, &QQuickControl::implicitContentHeightChanged, q, &QQuickPopup::implicitContentHeightChanged);
QObject::connect(popupItem, &QQuickControl::implicitBackgroundWidthChanged, q, &QQuickPopup::implicitBackgroundWidthChanged);
QObject::connect(popupItem, &QQuickControl::implicitBackgroundHeightChanged, q, &QQuickPopup::implicitBackgroundHeightChanged);
+ QObject::connect(popupItem, &QQuickControl::spacingChanged, q, &QQuickPopup::spacingChanged);
+ QObject::connect(popupItem, &QQuickControl::topInsetChanged, q, &QQuickPopup::topInsetChanged);
+ QObject::connect(popupItem, &QQuickControl::bottomInsetChanged, q, &QQuickPopup::bottomInsetChanged);
+ QObject::connect(popupItem, &QQuickControl::leftInsetChanged, q, &QQuickPopup::leftInsetChanged);
+ QObject::connect(popupItem, &QQuickControl::rightInsetChanged, q, &QQuickPopup::rightInsetChanged);
}
void QQuickPopupPrivate::closeOrReject()
diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
index c127ee3ae4..2dcad62432 100644
--- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
@@ -146,6 +146,7 @@ private slots:
void popupWindowPositionerRespectingScreenBounds_data();
void popupWindowPositionerRespectingScreenBounds();
void propagateTouchEvents();
+ void spacingAndInsetsAreRevaluatedWhenChanged();
private:
QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
@@ -3625,6 +3626,56 @@ void tst_QQuickPopup::propagateTouchEvents()
QTRY_VERIFY(!popup->isOpened());
}
+void tst_QQuickPopup::spacingAndInsetsAreRevaluatedWhenChanged()
+{
+ QQuickApplicationHelper helper(this, "simplepopup.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ auto *popup = window->contentItem()->findChild<QQuickPopup *>();
+ QVERIFY(popup);
+
+ QSignalSpy spacingSpy(popup, &QQuickPopup::spacingChanged);
+ QSignalSpy paddingSpy(popup, &QQuickPopup::paddingChanged);
+ QSignalSpy topInsetSpy(popup, &QQuickPopup::topInsetChanged);
+ QSignalSpy leftInsetSpy(popup, &QQuickPopup::leftInsetChanged);
+ QSignalSpy rightInsetSpy(popup, &QQuickPopup::rightInsetChanged);
+ QSignalSpy bottomInsetSpy(popup, &QQuickPopup::bottomInsetChanged);
+
+ const qreal initialSpacing = popup->spacing();
+ const qreal initialPadding = popup->padding();
+ const qreal initialTopInset = popup->topInset();
+ const qreal initialLeftInset = popup->leftInset();
+ const qreal initialRightInset = popup->rightInset();
+ const qreal initialBottomInset = popup->bottomInset();
+ const qreal offset = 5;
+
+ popup->setSpacing(initialSpacing + offset);
+ QCOMPARE(spacingSpy.count(), 1);
+ QCOMPARE(popup->spacing(), initialSpacing + offset);
+
+ popup->setPadding(initialPadding + offset);
+ QCOMPARE(paddingSpy.count(), 1);
+ QCOMPARE(popup->padding(), initialPadding + offset);
+
+ popup->setTopInset(initialTopInset + offset);
+ QCOMPARE(topInsetSpy.count(), 1);
+ QCOMPARE(popup->topInset(), initialTopInset + offset);
+
+ popup->setLeftInset(initialLeftInset + offset);
+ QCOMPARE(leftInsetSpy.count(), 1);
+ QCOMPARE(popup->leftInset(), initialLeftInset + offset);
+
+ popup->setRightInset(initialRightInset + offset);
+ QCOMPARE(rightInsetSpy.count(), 1);
+ QCOMPARE(popup->rightInset(), initialRightInset + offset);
+
+ popup->setBottomInset(initialBottomInset + offset);
+ QCOMPARE(bottomInsetSpy.count(), 1);
+ QCOMPARE(popup->bottomInset(), initialBottomInset + offset);
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
#include "tst_qquickpopup.moc"