2015-05-12 62 views
1

有没有办法在Rectangle中设置旋转点并简单地使用旋转属性而没有任何其他附加组件?我想用rotation: value * 180结合物业旋转Rectangle这样设置矩形的旋转点

Rectangle{ 
    id: body 
    rotation: value 
    anchors.centerIn: parent.Center 
    antialiasing: true 
} 
onValueChanged: body.rotation = value 

我只有大约父的左上角旋转。请帮我理解这种行为,或者建议我以另一种方式在中心实施轮换。

回答

4

rotation财产围绕其transformOrigin财产旋转项目顺时针这可能是这九个点之一:

enter image description here

所以,你可以旋转一个围绕他们的喜欢:

Rectangle{ 
    id: body 
    rotation: value 
    transformOrigin: Item.Center 
    anchors.centerIn: parent.Center 
    antialiasing: true 
} 

如果您想围绕你应该使用的任意点旋转Rotation变换类型:

Rectangle{ 
    id: body 
    transform: Rotation { origin.x: 25; origin.y: 25; angle: value} 
    anchors.centerIn: parent.Center 
    antialiasing: true 
} 
+0

谢谢,真的很有用 – user3417815