Hello, I am curious as to whether the following is expected behavior or a bug:
import QtQuick 2.5import QtQuick.Window 2.1 Window { id: window width: 1280; height: 960 visible: true Component { id: component Rectangle { width: 64; height:64 color: "blue" } } Item { id: root anchors.fill: parent Rectangle { anchors.right: parent.right width: 64; height:64 color: "red" MouseArea { anchors.fill: parent property var target: null onPressed: { if (oldParent) { // The blue rectangle is initially created as a child of oldParent. target = component.createObject(oldParent, {"x": 0, "y": 0}); } } onReleased: { if (oldParent) { // How can I transfer ownership to newParent? // The blue rectangle should stay alive as a child of newParent. // (It appears the following line is not sufficient!) target.parent = newParent; oldParent.destroy(); } } } } Item { id: oldParent; anchors.fill: parent } Item { id: newParent; anchors.fill: parent } } } Also, if there is a workaround to make this work (i.e. make the blue rectangle stay after the mouse is released), I would love to hear about it. I have posted about this on the forums, but I have not received a response so far. https://forum.qt.io/topic/61903/dynamically-created-item-destroyed-with-original-parent-despite-reparenting Best regards, kloffy
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest