
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPropertyAnimation class animates Qt propertiesMore...
| Header: | #include <QPropertyAnimation> |
| Since: | Qt 4.6 |
| Inherits: | QVariantAnimation |
| QPropertyAnimation(QObject * parent = 0) | |
| QPropertyAnimation(QObject * target, const QByteArray & propertyName, QObject * parent = 0) | |
| ~QPropertyAnimation() | |
| QByteArray | propertyName() const |
| void | setPropertyName(const QByteArray & propertyName) |
| void | setTargetObject(QObject * target) |
| QObject * | targetObject() const |
| virtual bool | event(QEvent * event) |
| virtual void | updateCurrentValue(const QVariant & value) |
| virtual void | updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) |
TheQPropertyAnimation class animates Qt properties
QPropertyAnimation interpolates overQt properties. As property values are stored inQVariants, the class inheritsQVariantAnimation, and supports animation of the samevariant types as its super class.
A class declaring properties must be aQObject. To make it possible to animate a property, it must provide a setter (so thatQPropertyAnimation 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:
QPropertyAnimation*animation=newQPropertyAnimation(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 theQObject 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 withQVariantAnimation that yourQVariant type is supported.
TheQVariantAnimation 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 theQPropertyAnimation 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 atQParallelAnimationGroup for an example.
See alsoQVariantAnimation,QAnimationGroup, andThe Animation Framework.
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:
| QByteArray | propertyName() const |
| void | setPropertyName(const QByteArray & propertyName) |
This property holds the target QObject for this animation.
This property defines the targetQObject for this animation.
Access functions:
| QObject * | targetObject() const |
| void | setTargetObject(QObject * target) |
Construct aQPropertyAnimation object.parent is passed toQObject's constructor.
Construct aQPropertyAnimation object.parent is passed toQObject's constructor. The animation changes the propertypropertyName ontarget. The default duration is 250ms.
See alsotargetObject andpropertyName.
Destroys theQPropertyAnimation instance.
[virtual protected]bool QPropertyAnimation::event(QEvent * event)Reimplemented fromQObject::event().
[virtual protected]void QPropertyAnimation::updateCurrentValue(constQVariant & value)Reimplemented fromQVariantAnimation::updateCurrentValue().
This virtual function is called byQVariantAnimation whenever the current value changes.value is the new, updated value. It updates the current value of the property on the target object.
See alsocurrentValue andcurrentTime.
[virtual protected]void QPropertyAnimation::updateState(QAbstractAnimation::State newState,QAbstractAnimation::State oldState)Reimplemented fromQAbstractAnimation::updateState().
If thestartValue is not defined when the state of the animation changes from Stopped to Running, the current property value is used as the initial value for the animation.
© 2016 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 theGNU 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.