diff options
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 8 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_popup.qml | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 3f3caf58..4852d08d 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -2216,8 +2216,12 @@ void QQuickPopup::componentComplete() { Q_D(QQuickPopup); d->complete = true; - if (!parentItem()) - setParentItem(qobject_cast<QQuickItem *>(parent())); + if (!parentItem()) { + if (QQuickItem *item = qobject_cast<QQuickItem *>(parent())) + setParentItem(item); + else if (QQuickWindow *window = qobject_cast<QQuickWindow *>(parent())) + setParentItem(window->contentItem()); + } if (d->visible) d->transitionManager.transitionEnter(); d->popupItem->componentComplete(); diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index ee98e2ae..d9630142 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1260,4 +1260,14 @@ TestCase { compare(control.y, (control.parent.height - control.height) / 2) window.destroy() } + + function test_windowParent() { + var control = popupControl.createObject(applicationWindow, {width: 100, height: 100}) + verify(control) + + control.open() + verify(control.visible) + + control.destroy() + } } |