New in version 4.6.
QPropertyAnimation interpolates over Qt properties . As property values are stored in
QVariant s, the class inherits
QVariantAnimation , and supports animation of the same
meta types as its super class.
A class declaring properties must be a
QObject . To make it possible to animate a property, it must provide a setter (so that
QPropertyAnimation can set the property’s value). Note that this makes it possible to animate many of Qt’s widgets. Let’s look at an example:
animation = QPropertyAnimation(myWidget, "geometry") animation.setDuration(10000) animation.setStartValue(QRect(0, 0, 100, 30)) animation.setEndValue(QRect(250, 250, 100, 30)) animation.start()
The property name and the
QObject instance of which property should be animated are passed to the constructor. You can then specify the start and end value of the property. The procedure is equal for properties in classes you have implemented yourself–just check with
QVariantAnimation that your
QVariant type is supported.
QVariantAnimation class description explains how to set up the animation in detail. Note, however, that if a start value is not set, the property will start at the value it had when the
QPropertyAnimation instance was created.
QPropertyAnimation works like a charm on its own. For complex animations that, for instance, contain several objects,
QAnimationGroup is provided. An animation group is an animation that can contain other animations, and that can manage when its animations are played. Look at
QParallelAnimationGroup for an example.
- class PySide6.QtCore.QPropertyAnimation([parent=None])¶
PySide6.QtCore.QPropertyAnimation(target, propertyName[, parent=None])
- Return type
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.