Home

QtVariantAnimation Class Reference
[QtCore module]

The QtVariantAnimation class provides an abstract base class for animations. More...

 #include <QtVariantAnimation>

This class is under development and is subject to change.

Inherits QtAbstractAnimation.

Inherited by QtPropertyAnimation.

Public Types

Properties

Public Functions

Signals

Protected Functions

Related Non-Members

Additional Inherited Members


Detailed Description

The QtVariantAnimation class provides an abstract base class for animations.

This class is part of {The Animation Framework}. It serves as a base class for property and item animations, with functions for shared functionality.

If you want to create an animation, you should look at QtPropertyAnimation instead.

You can then set start and end values for the property by calling setStartValue() and setEndValue(), and finally call start() to start the animation. When control goes back to the event loop, QtVariantAnimation will interpolate the property of the target object and emit the valueChanged signal. To react to a change in the current value you have to reimplement the updateCurrentValue virtual method.

There are two ways to affect how QtVariantAnimation interpolates the values. You can set an easing curve by calling setEasingCurve(), and configure the duration by calling setDuration(). You can change how the QVariants are interpolated by creating a subclass of QtVariantAnimation, and reimplementing the virtual interpolated() function.

See also QtPropertyAnimation and The Animation Framework.


Member Type Documentation

typedef QtVariantAnimation::KeyValue

This is a typedef for QPair<qreal, QVariant>.

typedef QtVariantAnimation::KeyValues

This is a typedef for QVector<KeyValue>


Property Documentation

currentValue : const QVariant

This property holds the current value of the animation.

This property describes the current value; an interpolation between the start value and the end value, using the current time for progress.

QtVariantAnimation calls the virtual updateCurrentValue() function when the current value changes. This is particularily useful for subclasses that need to track updates.

Access functions:

See also startValue and endValue.

duration : int

This property holds the duration of the animation.

This property describes the duration of the animation. The default duration is 250 milliseconds.

Access functions:

See also QtAbstractAnimation::duration().

easingCurve : QtEasingCurve

This property holds the easing curve of the animation.

This property defines the easing curve of the animation. By default, a linear easing curve is used, resulting in linear interpolation of the end property. For many animations, it's useful to try different easing curves, including QtEasingCurve::InCirc, which provides a circular entry curve, and QtEasingCurve::InOutElastic, which provides an elastic effect on the values of the interpolated property.

The easing curve is used with the interpolator, the interpolated() virtual function, the animation's duration, and loopCount, to control how the current value changes as the animation progresses.

Access functions:

endValue : QVariant

This property holds the end value of the animation.

This property describes the end value of the animation.

Access functions:

See also startValue.

startValue : QVariant

This property holds the optional start value of the animation.

This property describes the optional start value of the animation. If omitted, or if a null QVariant is assigned as the start value, the animation will use the current position of the end when the animation is started.

Access functions:

See also endValue.


Member Function Documentation

QtVariantAnimation::QtVariantAnimation ( QObject * parent = 0 )

Construct a QtVariantAnimation object. parent is passed to QtAbstractAnimation's constructor.

QtVariantAnimation::~QtVariantAnimation ()

Destroys the animation.

QVariant QtVariantAnimation::interpolated ( const QVariant & from, const QVariant & to, qreal progress ) const   [virtual protected]

This virtual function returns the linear interpolation between variants from and to, at progress, usually a value between 0 and 1. You can reimplement this function in a subclass of QtVariantAnimation to provide your own interpolation algorithm. Note that in order for the interpolation to work with a QtEasingCurve that return a value smaller than 0 or larger than 1 (such as QtEasingCurve::InBack) you should make sure that it can extrapolate. If the semantic of the datatype does not allow extrapolation this function should handle that gracefully.

See also QtEasingCurve.

QVariant QtVariantAnimation::keyValueAt ( qreal step ) const

Returns the key frame value for the given step. The given step must be in the range 0 to 1. If there is no KeyValue for step, it returns an invalid QVariant.

See also keyValues() and setKeyValueAt().

KeyValues QtVariantAnimation::keyValues () const

Returns the key frames of this animation.

See also keyValueAt() and setKeyValues().

void QtVariantAnimation::setKeyValueAt ( qreal step, const QVariant & value )

Creates a key frame at the given step with the given value. The given step must be in the range 0 to 1.

See also setKeyValues() and keyValueAt().

void QtVariantAnimation::setKeyValues ( const KeyValues & keyValues )

Replaces the current set of key frames with the given keyValues. the step of the key frames must be in the range 0 to 1.

See also keyValues() and keyValueAt().

void QtVariantAnimation::updateCurrentValue ( const QVariant & value )   [pure virtual protected]

This pure virtual function is called when the animated value is changed. value is the new value.

void QtVariantAnimation::valueChanged ( const QVariant & value )   [signal]

QtVariantAnimation emits this signal whenever the current value changes.

See also currentValue, startValue, and endValue.


Related Non-Members

void qRegisterAnimationInterpolator ( QVariant(* ) ( const T & from, const T & to, qreal progress ) func )   [static]

Registers a custom interpolator func for the template type T. The interpolator has to be registered before the animation is constructed. To unregister (and use the default interpolator) set func to 0.

Note: This function is thread-safe.


Copyright © 2009 Nokia Trademarks
Qt Solutions