CopperSpice API  1.7.2
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 &objName=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)
 
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 animates CopperSpice properties by looping from a starting value to an ending value. As property values are stored in QVariants, the class inherits QVariantAnimation, and supports animation of the same variant 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 the CopperSpice widgets.

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();

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.

The 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.

See also
QVariantAnimation, QAnimationGroup, Animation Technology

Constructor & Destructor Documentation

QPropertyAnimation::QPropertyAnimation ( QObject parent = nullptr)

Construct a QPropertyAnimation object. parent is passed to QObject's constructor.

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

Construct a QPropertyAnimation object. parent is passed to QObject's 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

This virtual method receives events to an object and should return true if the event event was recognized and processed. The event() method can be overridden to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QAbstractAnimation.

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.

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.

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