Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

a bug of Item position in Qt Quick2

$
0
0
I think this is a bug. When the rotation is 0, everything is ok, we can set new width or height normally. When the rotation is not 0, if I set the new width or height, I find that the item will move to other place while the x and y property stay the same. You can use the following code to test import QtQuick 2.0   Rectangle {     id: root     width: 800     height: 800     color: "yellow"     Rectangle {         id: tester         rotation: 40         width: 50         height: 50         x:200         y:200         color: "black"         NumberAnimation on width {             loops: Animation.Infinite             from: 50             to: 300             duration: 1000         }         onWidthChanged: {             var pos = mapToItem(tester.parent,0, 0)             console.log("this is the position of the topleft corner of item tester:"+pos.x)             console.log("this is the x pos of item tester:"+tester.x)         }     } } In my app, I want to add a controller to let user resize the item in the view(similar to what Qt Designer does), I want the Item to stay at the same position (whether the topleft corner keeps still or the center point keeps still is ok) when the rotation is not zero, but I don’t know how to do that. Hope someone can help me, thank you.

Viewing all articles
Browse latest Browse all 18427

Trending Articles