The Animation framework

For now, we have calculated and applied new positions for our graphics items manually. However, Qt provides a way to do it automatically, called the Animation framework.

The framework is an abstract implementation of animations, so it can be applied to any QObject, such as widgets, or even plain variables. Graphics, items can be animated too, and we will get to this topic soon. Animations are not restricted to the object's coordinates. You can animate color, opacity, or a completely invisible property.

To create an animation, you typically need to perform the following steps:

  1. Create an animation object (such as QPropertyAnimation)
  2. Set the object that should be animated
  3. Set the name of the property to be animated

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.