Important: Please read the Qt Code of Conduct -

Custom animation classes?

  • I'm interested in doing some sophisticated physics based animations of QML elements.
    I know I can perform the motion calculations to predict the path of the objects then use a PathAnimation object.
    This is fine unless I have to change the simulation during the animation.

    Can anyone offer any hints on how to write a custom animation class?
    If I implemented that I could incrementally calculate motion instead of having to predict / interrupt / predict.


  • After a bit more review it appears the PathAnimation will not work. It animates the position of the item but can't be applied to any arbitrary property. (You can't use a path animation to control rotation).

    So it really looks like I have to implement a custom animation class to get what I want.

  • Hi, you may be able to extend the classes QAbstractAnimation or QPropertyAnimation and use it in QML. I haven't tried that myself but it should work I guess, take a look at the code at "qtbase/src/corelib/animation":

  • Thank you Xander. Hopefully it's easier to understand/refactor than to just re-invent!

Log in to reply