gpt4 book ai didi

qt - 设置矩形的旋转点

转载 作者:行者123 更新时间:2023-12-05 08:34:17 28 4
gpt4 key购买 nike

有没有一种方法可以在 Rectangle 中设置旋转点并且只使用旋转属性而不需要任何其他附加组件?我想像这样旋转一个绑定(bind)属性为 rotation: value * 180Rectangle

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

我只得到了围绕父对象左上角的旋转。请帮助我理解这种行为或建议我另一种实现中心旋转的方法。

最佳答案

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
}

关于qt - 设置矩形的旋转点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30180106/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com