From 034f1728ea56f3750625905a3baedabd52144faf Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Oct 2016 11:59:09 +0200 Subject: [PATCH] QmlDesigner: Set QQuickItem parent if item is written to a property The QQuickEngine does the same. Before in cases like this: Item { Slider { handle: Item { } } } The item parent of the handle was the root item instead of the slider. Change-Id: Ia022c82c6d85c2a957763c56639ac77bca9297e6 Reviewed-by: Tim Jenssen --- .../qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 1695e6e55f4..c3d0437bf6a 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -336,6 +336,10 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c list.append(object); } else if (isObject(property)) { property.write(objectToVariant(object)); + + if (QQuickItem *item = qobject_cast(object)) + if (QQuickItem *newParentItem = qobject_cast(newParent)) + item->setParentItem(newParentItem); } Q_ASSERT(objectToVariant(object).isValid());