diff options
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 10 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_popup.qml | 18 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 2a48473a..22b399b1 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -929,8 +929,13 @@ void QQuickPopup::setWidth(qreal width) void QQuickPopup::resetWidth() { Q_D(QQuickPopup); + if (!d->hasWidth) + return; + d->hasWidth = false; d->popupItem->resetWidth(); + if (d->popupItem->isVisible()) + d->reposition(); } /*! @@ -954,8 +959,13 @@ void QQuickPopup::setHeight(qreal height) void QQuickPopup::resetHeight() { Q_D(QQuickPopup); + if (!d->hasHeight) + return; + d->hasHeight = false; d->popupItem->resetHeight(); + if (d->popupItem->isVisible()) + d->reposition(); } /*! diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index ae1c7185..8d8f94b7 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -355,6 +355,24 @@ TestCase { control.destroy() } + function test_resetSize() { + var control = popupControl.createObject(testCase, {visible: true, margins: 0}) + verify(control) + + control.width = control.implicitWidth = testCase.width + 10 + control.height = control.implicitHeight = testCase.height + 10 + + compare(control.width, testCase.width + 10) + compare(control.height, testCase.height + 10) + + control.width = undefined + control.height = undefined + compare(control.width, testCase.width) + compare(control.height, testCase.height) + + control.destroy() + } + function test_negativeMargins() { var control = popupControl.createObject(testCase, {implicitWidth: testCase.width, implicitHeight: testCase.height}) verify(control) |