PySide6.QtCore.QPropertyAnimation¶
- class QPropertyAnimation¶
- The - QPropertyAnimationclass animates Qt properties. More…- Added in version 4.6. - Synopsis¶- Properties¶- propertyNameᅟ- The target property name for this animation
- targetObjectᅟ- The target QObject for this animation
 - Methods¶- def - __init__()
- def - propertyName()
- def - targetObject()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - QPropertyAnimationinterpolates over Qt properties . As property values are stored in- QVariants, the class inherits- QVariantAnimation, and supports animation of the same- meta typesas 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- QPropertyAnimationcan set the property’s value). Note that this makes it possible to animate many of Qt’s widgets. Let’s look at an example:- from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QPushButton from PySide6.QtCore import QPropertyAnimation class MyButtonWidget(QWidget): # public MyButtonWidget(QWidget parent = None) def __init__(self, QWidget(parent): button = QPushButton(tr("Animated Button"), self) anim = QPropertyAnimation(button, "pos", self) anim.setDuration(10000) anim.setStartValue(QPoint(0, 0)) anim.setEndValue(QPoint(100, 250)) anim.start() if __name__ == "__main__": a = QApplication(argc, argv) buttonAnimWidget = MyButtonWidget() buttonAnimWidget.resize(QSize(800, 600)) buttonAnimWidget.show() return a.exec() - Note - You can also control an animation’s lifespan by choosing a - delete policywhile starting the animation.- The property name and the - QObjectinstance 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- QVariantAnimationthat your- QVarianttype is supported.- The - QVariantAnimationclass 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- QPropertyAnimationinstance was created.- QPropertyAnimationworks like a charm on its own. For complex animations that, for instance, contain several objects,- QAnimationGroupis provided. An animation group is an animation that can contain other animations, and that can manage when its animations are played. Look at- QParallelAnimationGroupfor an example.- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property propertyNameᅟ: QByteArray¶
 - This property holds the target property name for this animation. - This property defines the target property name for this animation. The property name is required for the animation to operate. - Access functions:
 - This property holds the target - QObjectfor this animation..- This property defines the target - QObjectfor this animation.- Access functions:
 - Construct a - QPropertyAnimationobject.- parentis passed to- QObject‘s constructor.- __init__(target, propertyName[, parent=None])
- Parameters:
- target – - QObject
- propertyName – - QByteArray
- parent – - QObject
 
 
 - Construct a - QPropertyAnimationobject.- parentis passed to- QObject‘s constructor. The animation changes the property- propertyNameon- target. The default duration is 250ms.- See also - propertyName()¶
- Return type:
 - See also 
 - Getter of property - propertyNameᅟ.- setPropertyName(propertyName)¶
- Parameters:
- propertyName – - QByteArray
 - See also 
 - Setter of property - propertyNameᅟ.- Setter of property - targetObjectᅟ.- targetObject()¶
- Return type:
 - See also 
 - Getter of property - targetObjectᅟ.