Details
-
Suggestion
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.0.2
Description
Reparenting (ParentChange) only supports absolute element coordinates. It would be useful if reparenting would support/respect anchors as well, since anchors is a much cleaner way to specify relative positions.
Currently, due to limitations of the ParentChange operation, anchors are completely ignored and the following code doesn't work as some would expect (the blueRect jumps down on reparenting). This happens because anchors are not reevaluated after ParentChange and since x/y coordinates of the blueRect become relative to the redRect instead of the topItem:
Item { id: topItem width: 200; height: 200 Rectangle { id: redRect clip: true width: 100; height: 100 x: 20 y: 20 color: "red" } Rectangle { id: blueRect width: 50; height: 50 color: "blue" anchors { top: redRect.top; left: redRect.right } states: State { name: "reparented" AnchorChanges { target: blueRect; anchors.left: redRect.left; } } transitions: Transition { SequentialAnimation{ AnchorAnimation { duration: 1000 } ScriptAction{ script: blueRect.parent = redRect } } } MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } } }
It would be cleaner/better/useful if reparenting would trigger anchors reevaluation if anchors were specified. (See also comments to QTBUG-30723)