Unsolved Restart Animation inside OnStopped event
-
What about this code?
SequentialAnimation { id: anim PropertyAction { target: rotSpin; property: "origin.x"; value: xCenterNeedle } PropertyAction { target: rotSpin; property: "origin.y"; value: yCenterNeedle } NumberAnimation { id: numAnim; target: rotSpin; property: "angle"; easing.type: Easing.Linear; to: _degree; duration: _time; } onStopped: { _degree = 123 _time = 234 anim.loops = 1; anim.start(); return null; } }
Is this allowed and safe?
-
Hi
Why do you wanna restart animation with OnStopped event?
Looks like you are looking for an infinite animation?
If this is your case , there is a loops property in Animation
If set to Animation.Infinite, the animation will continuously repeat until it is explicitly stopped - either by setting the running property to false, or by calling the stop() method.
In your case you will have just to add loops after id: anim
id: anim loops: Animation.Infinite
?
-
Yes, I'm already using that. Here I explained the reason of my request:
https://forum.qt.io/topic/85693/change-numberanimation-while-running
basically, I need to reach a specific angle when an event fires. Using Animation.Infinite, it seems I cannot retargetting the Animation properties. Hence my workaround was to stop the animation, in the onStopped event calculate how much it needs to go further and restart the animation with the new target and loops = 1.