CopperSpice API  1.9.1
QPropertyAnimation Class Reference

The QPropertyAnimation class animates properties. More...

Inheritance diagram for QPropertyAnimation:
QVariantAnimation QAbstractAnimation QObject

Public Methods

 QPropertyAnimation (QObject *parent=nullptr)
 
 QPropertyAnimation (QObject *target, const QString &propertyName, QObject *parent=nullptr)
 
 ~QPropertyAnimation ()
 
QString propertyName () const
 
void setPropertyName (const QString &propertyName)
 
void setTargetObject (QObject *target)
 
QObjecttargetObject () const
 
- Public Methods inherited from QVariantAnimation
 QVariantAnimation (QObject *parent=nullptr)
 
 ~QVariantAnimation ()
 
QVariant currentValue () const
 
int duration () const override
 
QEasingCurve easingCurve () const
 
QVariant endValue () const
 
QVariant keyValueAt (double step) const
 
QVector< QVariantAnimation::ValuePairkeyValues () const
 
void setDuration (int msecs)
 
void setEasingCurve (const QEasingCurve &easing)
 
void setEndValue (const QVariant &value)
 
void setKeyValueAt (double step, const QVariant &value)
 
void setKeyValues (const QVector< QVariantAnimation::ValuePair > &keyValues)
 
void setStartValue (const QVariant &value)
 
QVariant startValue () const
 
- Public Methods inherited from QAbstractAnimation
 QAbstractAnimation (QObject *parent=nullptr)
 
virtual ~QAbstractAnimation ()
 
int currentLoop () const
 
int currentLoopTime () const
 
int currentTime () const
 
Direction direction () const
 
QAnimationGroupgroup () const
 
int loopCount () const
 
void setDirection (Direction direction)
 
void setLoopCount (int loopCount)
 
State state () const
 
int totalDuration () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Protected Methods

bool event (QEvent *event) override
 
void updateCurrentValue (const QVariant &value) override
 
void updateState (QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override
 
- Protected Methods inherited from QVariantAnimation
bool event (QEvent *event) override
 
virtual QVariant interpolated (const QVariant &from, const QVariant &to, double progress) const
 
void updateCurrentTime (int) override
 
void updateState (QAbstractAnimation::State newState, QAbstractAnimation::State oldState) override
 
- Protected Methods inherited from QAbstractAnimation
virtual void updateDirection (QAbstractAnimation::Direction direction)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 propertyName
 
 targetObject
 
- Properties inherited from QVariantAnimation
 currentValue
 
 duration
 
 easingCurve
 
 endValue
 
 startValue
 
- Properties inherited from QAbstractAnimation
 currentLoop
 
 currentTime
 
 direction
 
 duration
 
 loopCount
 
 state
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Typedefs inherited from QVariantAnimation
using ValuePair = QPair< double, QVariant >
 
- Public Types inherited from QAbstractAnimation
enum  DeletionPolicy
 
enum  Direction
 
enum  State
 
- Public Signals inherited from QVariantAnimation
void valueChanged (const QVariant &value)
 
- Public Signals inherited from QAbstractAnimation
void currentLoopChanged (int currentLoop)
 
void directionChanged (QAbstractAnimation::Direction newDirection)
 
void finished ()
 
void stateChanged (QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QAbstractAnimation
void pause ()
 
void resume ()
 
void setCurrentTime (int msecs)
 
void setPaused (bool paused)
 
void start (QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
 
void stop ()
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Detailed Description

QPropertyAnimation updates the value of a given property by looping from a starting value to an ending value. The intended purpose is to produce a smooth animation. The property must have both a read and write method.

If a start value is not set the property will start at the value it had when the QPropertyAnimation instance was created.

For complex animations which animate several objects consider using a QAnimationGroup. An animation group is an animation that can contain other animations and can manage when its animations are played. Refer to QParallelAnimationGroup for an example.

Example

Constructing a QPropertyAnimation requires an object and the name of a property which belongs to the given object.

QFrame *myWidget = new QFrame(this);
QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(0, 0, 100, 30));
animation->setEndValue(QRect(250, 250, 100, 30));
animation->start();

This class inherits from QVariantAnimation. For more information about how to set up the animation refer to the detailed description for that class.

See also
QVariantAnimation, QAnimationGroup, Animation Technology, Properties

Constructor & Destructor Documentation

QPropertyAnimation::QPropertyAnimation ( QObject parent = nullptr)

Construct a QPropertyAnimation object. The parent is passed to the QObject constructor.

QPropertyAnimation::QPropertyAnimation ( QObject target,
const QString propertyName,
QObject parent = nullptr 
)

Construct a QPropertyAnimation object. The parent is passed to the QObject constructor. The animation changes the property propertyName on target. The default duration is 250ms.

See also
targetObject, propertyName
QPropertyAnimation::~QPropertyAnimation ( )

Destroys the current QPropertyAnimation object.

Method Documentation

bool QPropertyAnimation::event ( QEvent event)
overrideprotectedvirtual

Reimplemented from QAbstractAnimation::event()

QString QPropertyAnimation::propertyName ( ) const

Returns the property target name for this animation.

void QPropertyAnimation::setPropertyName ( const QString propertyName)

Sets the value of the property target name property to propertyName.

void QPropertyAnimation::setTargetObject ( QObject target)

Sets the value of the target object property to target.

QObject * QPropertyAnimation::targetObject ( ) const

Returns the target object for this animation.

void QPropertyAnimation::updateCurrentValue ( const QVariant value)
overrideprotectedvirtual

This virtual method is called by QVariantAnimation whenever the current value changes. The value is the new updated value. It updates the current value of the property on the target object.

See also
currentValue, currentTime

Implements QVariantAnimation::updateCurrentValue()

void QPropertyAnimation::updateState ( QAbstractAnimation::State  newState,
QAbstractAnimation::State  oldState 
)
overrideprotectedvirtual

This method is called by QAbstractAnimation when the state of the animation is changed from oldState to newState. If the startValue property does not contain a value when the state of the animation changes from Stopped to Running, the currentValue property will not be modified.

Reimplemented from QAbstractAnimation::updateState()

Property Documentation

QPropertyAnimation::propertyName

This property holds the target property name for this animation. The property name is required for the animation to operate.

PropertiesClass Methods
read propertyName
write setPropertyName
QPropertyAnimation::targetObject

This property holds the target QObject for this animation.

PropertiesClass Methods
read targetObject
write setTargetObject