From 8cb02e23abbefc9d020707fc1a2d8b6eb4e103b6 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 1 Oct 2013 08:36:03 +0200 Subject: [PATCH] A dynamically created Window can have a parent Window So far the parent relationship has existed only for Items. parent is still not exposed as a property of Window, but since it was possible to give a parent parameter to Component.createObject(), it makes sense to try to interpret it as a Window in that case. So now a Window can be created with another Window as its parent just as an Item can be created with a parent Item. Task-number: QTBUG-33644 Change-Id: I796198a38bd47253eef462c80f5098825451c59c Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> --- src/quick/items/qquickitemsmodule.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 7615759..0b20c28 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -87,16 +87,24 @@ static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent) { - QQuickItem *item = qmlobject_cast(obj); - if (!item) - return QQmlPrivate::IncompatibleObject; - QQuickItem *parentItem = qmlobject_cast(parent); - if (!parentItem) - return QQmlPrivate::IncompatibleParent; - - item->setParentItem(parentItem); - return QQmlPrivate::Parented; + if (parentItem) { + QQuickItem *item = qmlobject_cast(obj); + if (!item) + return QQmlPrivate::IncompatibleObject; + item->setParentItem(parentItem); + return QQmlPrivate::Parented; + } else { + QQuickWindow *parentWindow = qmlobject_cast(parent); + if (parentWindow) { + QQuickWindow *win = qmlobject_cast(obj); + if (!win) + return QQmlPrivate::IncompatibleObject; + win->setTransientParent(parentWindow); + return QQmlPrivate::Parented; + } + } + return QQmlPrivate::IncompatibleParent; } static bool compareQQuickAnchorLines(const void *p1, const void *p2) -- 2.7.4