RotationAnimation: how to rotate about non-center coordinates?
Solved
QML and Qt Quick
-
I'm using RotationAnimation for the first time. This works fine. The image
is 190 x 44 pixels and rotates about the center at x=95, y=22. I would like
to have it rotate about 164, 22 instead. How can I do this with
RotationAnimation? If it can't be done this way, what is the proper way to
do it?RotationAnimation on rotation {
from: 0
to: 360
duration: 3000
direction: RotationAnimation.Clockwise
loops: Animation.Infinite
} -
import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 Rectangle { width: 190 height: 44 color: "red" anchors.centerIn: parent transform: Rotation { origin.x: 164 origin.y: 22 RotationAnimation on angle { from: 0 to: 360 duration: 3000 direction: RotationAnimation.Clockwise loops: Animation.Infinite } } } }
-
You can use QML Rotation.
-
import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 Rectangle { width: 190 height: 44 color: "red" anchors.centerIn: parent transform: Rotation { origin.x: 164 origin.y: 22 RotationAnimation on angle { from: 0 to: 360 duration: 3000 direction: RotationAnimation.Clockwise loops: Animation.Infinite } } } }