use*_*815 2 qt rotation qml qt-quick qtquick2
有没有办法设置旋转点Rectangle并简单地使用旋转属性而不需要任何其他附加组件?我想旋转Rectangle与绑定的属性rotation: value * 180是这样
Rectangle{
id: body
rotation: value
anchors.centerIn: parent.Center
antialiasing: true
}
onValueChanged: body.rotation = value
Run Code Online (Sandbox Code Playgroud)
我只绕父母的左上角旋转.请帮助我理解这种行为或建议我在中心实施轮换的另一种方法.
rotation属性围绕其transformOrigin属性顺时针旋转项目,这可能是以下九点之一:

所以你可以围绕其中一个旋转,如:
Rectangle{
id: body
rotation: value
transformOrigin: Item.Center
anchors.centerIn: parent.Center
antialiasing: true
}
Run Code Online (Sandbox Code Playgroud)
如果要围绕任意点旋转,则应使用Rotation变换类型:
Rectangle{
id: body
transform: Rotation { origin.x: 25; origin.y: 25; angle: value}
anchors.centerIn: parent.Center
antialiasing: true
}
Run Code Online (Sandbox Code Playgroud)