设置矩形的旋转点
问题描述:
有没有办法在Rectangle
中设置旋转点并简单地使用旋转属性而没有任何其他附加组件?我想用rotation: value * 180
结合物业旋转Rectangle
这样设置矩形的旋转点
Rectangle{
id: body
rotation: value
anchors.centerIn: parent.Center
antialiasing: true
}
onValueChanged: body.rotation = value
我只有大约父的左上角旋转。请帮我理解这种行为,或者建议我以另一种方式在中心实施轮换。
答
rotation
财产围绕其transformOrigin
财产旋转项目顺时针这可能是这九个点之一:
所以,你可以旋转一个围绕他们的喜欢:
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
}
谢谢,真的很有用 – user3417815