Just use a placeholder to center your rotating item into. Here is an example – the rotating item will move with the mouse cursor as it rotates around its center and changes width:
Rectangle {
id: root
width: 800
height: 800
color: "yellow"
MouseArea {
id: cursorLocation
hoverEnabled: true
anchors.fill: parent
}
Item { // placeholder
width: 50
height: 50
x: cursorLocation.mouseX - width/2
y: cursorLocation.mouseY - height/2
Rectangle {
id: tester
anchors.centerIn: parent
width: 50
height: 50
color: "black"
NumberAnimation on rotation {
loops: Animation.Infinite
from: 0
to: 360
duration: 1000
}
NumberAnimation on width {
loops: Animation.Infinite
from: 50
to: 300
duration: 1000
}
}
}
}
↧