[Solved] QPropertyAnimation: How to move a widget ?
-
I have a requirement where I need to move the widget from one position to the other with some animation effect.
For eg: I need to move my widget from (10,0) to (150,0) and then back to (10,0)How to implement this.
Thanks
-
It's a matter of creating "QPropertyAnimation":http://qt-project.org/doc/qt-4.8/qpropertyanimation.html instance, setting endValue and/or keyframes, duration and starting animation. There is an example in QPropertyAnimation docs. If there is more animations involved you may consider using "State Machine Framework":http://qt-project.org/doc/qt-4.8/statemachine-api.html.
-
Thanks for the help,
I got the solution and its working. I used two QPropertyAnimations one from (10,0) to (150,0) then another from (150,0) to (10,0) when first animation is finished.
Regards
Soumitra. -
In that case, you could also use keyframes and only one QPropertyAnimation. Check second example: http://qt-project.org/doc/qt-4.8/animation-overview.html#animating-qt-properties
-
Thankd for the help again.
Can you tell me where can I find more examples on State machine and QPropertyAnimation.