diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-10-01 08:36:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-03 17:48:34 +0200 |
commit | 8cb02e23abbefc9d020707fc1a2d8b6eb4e103b6 (patch) | |
tree | ee0ad44f7e37bd53c220d1ee745c3f3ce09d7c32 /src/quick/items/qquickitemsmodule.cpp | |
parent | 7959eca9f15f6a2a614f247712a0ce491f877708 (diff) |
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>
Diffstat (limited to 'src/quick/items/qquickitemsmodule.cpp')
-rw-r--r-- | src/quick/items/qquickitemsmodule.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 761575910f..0b20c28ab9 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<QQuickItem *>(obj); - if (!item) - return QQmlPrivate::IncompatibleObject; - QQuickItem *parentItem = qmlobject_cast<QQuickItem *>(parent); - if (!parentItem) - return QQmlPrivate::IncompatibleParent; - - item->setParentItem(parentItem); - return QQmlPrivate::Parented; + if (parentItem) { + QQuickItem *item = qmlobject_cast<QQuickItem *>(obj); + if (!item) + return QQmlPrivate::IncompatibleObject; + item->setParentItem(parentItem); + return QQmlPrivate::Parented; + } else { + QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent); + if (parentWindow) { + QQuickWindow *win = qmlobject_cast<QQuickWindow *>(obj); + if (!win) + return QQmlPrivate::IncompatibleObject; + win->setTransientParent(parentWindow); + return QQmlPrivate::Parented; + } + } + return QQmlPrivate::IncompatibleParent; } static bool compareQQuickAnchorLines(const void *p1, const void *p2) |