0
我有一個對象,我想旋轉一個點,其座標存儲在屬性offsetx
,offsety
中。這是我的目標:變換內QML對象屬性
Rectangle {
id: rec1
property int offsetx: width/2
property int offsety: height/2
height: 50
width: 50
color: "blue"
x: originx - offsetx
y: originy - offsety
transform: Rotation { origin.x: offsetx ; origin.y: offsety; angle: 45}
}
變換將既不承認也不offsetx
offsety
,而position屬性X,Y,這既取決於髒性能,做工精細。如果我寫rec1.offsetx
那麼轉換就可以識別它,但是如果我想要實例化這些矩形中的很多(它們不一定具有id),則使用此方法可能會出現問題。