Qt 4.8
|
The QAbstractAnimation class is the base of all animations. More...
#include <qabstractanimation.h>
Public Types | |
enum | DeletionPolicy { KeepWhenStopped = 0, DeleteWhenStopped } |
enum | Direction { Forward, Backward } |
This enum describes the direction of the animation when in Running state. More... | |
enum | State { Stopped, Paused, Running } |
This enum describes the state of the animation. More... | |
Public Slots | |
void | pause () |
Pauses the animation. More... | |
void | resume () |
Resumes the animation after it was paused. More... | |
void | setCurrentTime (int msecs) |
void | setPaused (bool) |
If paused is true, the animation is paused. More... | |
void | start (QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped) |
Starts the animation. More... | |
void | stop () |
Stops the animation. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | currentLoopChanged (int currentLoop) |
QAbstractAnimation emits this signal whenever the current loop changes. More... | |
void | directionChanged (QAbstractAnimation::Direction) |
QAbstractAnimation emits this signal whenever the direction has been changed. More... | |
void | finished () |
QAbstractAnimation emits this signal after the animation has stopped and has reached the end. More... | |
void | stateChanged (QAbstractAnimation::State newState, QAbstractAnimation::State oldState) |
QAbstractAnimation emits this signal whenever the state of the animation has changed from oldState to newState. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
int | currentLoop () const |
int | currentLoopTime () const |
Returns the current time inside the current loop. More... | |
int | currentTime () const |
Direction | direction () const |
virtual int | duration () const =0 |
QAnimationGroup * | group () const |
If this animation is part of a QAnimationGroup, this function returns a pointer to the group; otherwise, it returns 0. More... | |
int | loopCount () const |
QAbstractAnimation (QObject *parent=0) | |
Constructs the QAbstractAnimation base class, and passes parent to QObject's constructor. More... | |
void | setDirection (Direction direction) |
void | setLoopCount (int loopCount) |
State | state () const |
int | totalDuration () const |
Returns the total and effective duration of the animation, including the loop count. More... | |
virtual | ~QAbstractAnimation () |
Stops the animation if it's running, then destroys the QAbstractAnimation. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
bool | event (QEvent *event) |
Reimplemented Function More... | |
QAbstractAnimation (QAbstractAnimationPrivate &dd, QObject *parent=0) | |
virtual void | updateCurrentTime (int currentTime)=0 |
This pure virtual function is called every time the animation's currentTime changes. More... | |
virtual void | updateDirection (QAbstractAnimation::Direction direction) |
This virtual function is called by QAbstractAnimation when the direction of the animation is changed. More... | |
virtual void | updateState (QAbstractAnimation::State newState, QAbstractAnimation::State oldState) |
This virtual function is called by QAbstractAnimation when the state of the animation is changed from oldState to newState. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
int | currentLoop |
the current loop of the animation More... | |
int | currentTime |
the current time and progress of the animation More... | |
Direction | direction |
the direction of the animation when it is in Running state. More... | |
int | duration |
the duration of the animation. More... | |
int | loopCount |
the loop count of the animation More... | |
State | state |
state of the animation. More... | |
Additional Inherited Members | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QAbstractAnimation class is the base of all animations.
The class defines the functions for the functionality shared by all animations. By inheriting this class, you can create custom animations that plug into the rest of the animation framework.
The progress of an animation is given by its current time (currentLoopTime()), which is measured in milliseconds from the start of the animation (0) to its end (duration()). The value is updated automatically while the animation is running. It can also be set directly with setCurrentTime().
At any point an animation is in one of three states: QAbstractAnimation::Running, QAbstractAnimation::Stopped, or QAbstractAnimation::Paused–as defined by the QAbstractAnimation::State enum. The current state can be changed by calling start(), stop(), pause(), or resume(). An animation will always reset its current time when it is started. If paused, it will continue with the same current time when resumed. When an animation is stopped, it cannot be resumed, but will keep its current time (until started again). QAbstractAnimation will emit stateChanged() whenever its state changes.
An animation can loop any number of times by setting the loopCount property. When an animation's current time reaches its duration(), it will reset the current time and keep running. A loop count of 1 (the default value) means that the animation will run one time. Note that a duration of -1 means that the animation will run until stopped; the current time will increase indefinitely. When the current time equals duration() and the animation is in its final loop, the QAbstractAnimation::Stopped state is entered, and the finished() signal is emitted.
QAbstractAnimation provides pure virtual functions used by subclasses to track the progress of the animation: duration() and updateCurrentTime(). The duration() function lets you report a duration for the animation (as discussed above). The animation framework calls updateCurrentTime() when current time has changed. By reimplementing this function, you can track the animation progress. Note that neither the interval between calls nor the number of calls to this function are defined; though, it will normally be 60 updates per second.
By reimplementing updateState(), you can track the animation's state changes, which is particularly useful for animations that are not driven by time.
Definition at line 60 of file qabstractanimation.h.
Enumerator | |
---|---|
KeepWhenStopped | |
DeleteWhenStopped |
Definition at line 84 of file qabstractanimation.h.
This enum describes the direction of the animation when in Running state.
Enumerator | |
---|---|
Forward | |
Backward |
Definition at line 73 of file qabstractanimation.h.
This enum describes the state of the animation.
Enumerator | |
---|---|
Stopped | |
Paused | |
Running |
Definition at line 78 of file qabstractanimation.h.
QAbstractAnimation::QAbstractAnimation | ( | QObject * | parent = 0 | ) |
Constructs the QAbstractAnimation base class, and passes parent to QObject's constructor.
Definition at line 640 of file qabstractanimation.cpp.
|
virtual |
Stops the animation if it's running, then destroys the QAbstractAnimation.
If the animation is part of a QAnimationGroup, it is automatically removed before it's destroyed.
Definition at line 662 of file qabstractanimation.cpp.
|
protected |
Definition at line 650 of file qabstractanimation.cpp.
int QAbstractAnimation::currentLoop | ( | ) | const |
Referenced by QSequentialAnimationGroupPrivate::animationInsertedAt(), and setLoopCount().
|
signal |
QAbstractAnimation emits this signal whenever the current loop changes.
currentLoop is the current loop.
Referenced by setCurrentTime().
int QAbstractAnimation::currentLoopTime | ( | ) | const |
Returns the current time inside the current loop.
It can go from 0 to duration().
Definition at line 898 of file qabstractanimation.cpp.
Referenced by QUnifiedTimer::closestPauseAnimationTimeToFinish(), QDeclarativeAbstractAnimation::currentTime(), and ParallelAnimationWrapper::updateState().
int QAbstractAnimation::currentTime | ( | ) | const |
Referenced by QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QAnimationGroupPrivate::animationRemoved(), QSequentialAnimationGroupPrivate::animationRemoved(), currentLoopTime(), QSmoothedAnimation::init(), QParallelAnimationGroupPrivate::shouldAnimationStart(), and QParallelAnimationGroup::updateCurrentTime().
Direction QAbstractAnimation::direction | ( | ) | const |
|
signal |
QAbstractAnimation emits this signal whenever the direction has been changed.
newDirection is the new direction.
Referenced by setDirection().
|
pure virtual |
Implemented in TickAnimationProxy< T, method >, TickAnimationProxy< QDeclarativeParticlesPrivate, &QDeclarativeParticlesPrivate::tick >, QTickAnimationProxy< T, method >, QActionAnimation, QDeclarativeTimeLine, QVariantAnimation, QSmoothedAnimation, QSequentialAnimationGroup, QPauseAnimation, and QParallelAnimationGroup.
Referenced by setCurrentTime(), setDirection(), and totalDuration().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QObject.
Reimplemented in QVariantAnimation, QSequentialAnimationGroup, QAnimationGroup, QPropertyAnimation, QPauseAnimation, and QParallelAnimationGroup.
Definition at line 1067 of file qabstractanimation.cpp.
Referenced by QPauseAnimation::event(), QAnimationGroup::event(), and QVariantAnimation::event().
|
signal |
QAbstractAnimation emits this signal after the animation has stopped and has reached the end.
This signal is emitted after stateChanged().
QAnimationGroup * QAbstractAnimation::group | ( | ) | const |
If this animation is part of a QAnimationGroup, this function returns a pointer to the group; otherwise, it returns 0.
Definition at line 698 of file qabstractanimation.cpp.
Referenced by QStateMachinePrivate::applyProperties(), QAnimationGroup::insertAnimation(), QDeclarativeTransitionPrivate::QDeclarativeTransitionPrivate(), and QPropertyAnimation::updateState().
int QAbstractAnimation::loopCount | ( | ) | const |
Referenced by QSequentialAnimationGroupPrivate::animationRemoved(), setDirection(), setLoopCount(), and totalDuration().
|
slot |
Pauses the animation.
When the animation is paused, state() returns Paused. The value of currentTime will remain unchanged until resume() or start() is called. If you want to continue from the current time, call resume().
Definition at line 1019 of file qabstractanimation.cpp.
Referenced by QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QSequentialAnimationGroup::addPause(), QParallelAnimationGroupPrivate::applyGroupState(), QSequentialAnimationGroup::insertPause(), QDeclarativeAbstractAnimation::setPaused(), setPaused(), and QDeclarativeTimeLine::sync().
|
slot |
Resumes the animation after it was paused.
When the animation is resumed, it emits the resumed() and stateChanged() signals. The currenttime is not changed.
Definition at line 1037 of file qabstractanimation.cpp.
Referenced by QDeclarativeAbstractAnimation::setPaused(), and setPaused().
|
slot |
Definition at line 925 of file qabstractanimation.cpp.
Referenced by QSequentialAnimationGroupPrivate::advanceForwards(), QDeclarativeAbstractAnimation::complete(), QSequentialAnimationGroupPrivate::rewindForwards(), QDeclarativeAbstractAnimation::setCurrentTime(), QUnifiedTimer::updateAnimationsTime(), and QParallelAnimationGroup::updateCurrentTime().
void QAbstractAnimation::setDirection | ( | Direction | direction | ) |
Definition at line 763 of file qabstractanimation.cpp.
Referenced by QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QParallelAnimationGroup::updateDirection(), and QParallelAnimationGroup::updateState().
void QAbstractAnimation::setLoopCount | ( | int | loopCount | ) |
Definition at line 826 of file qabstractanimation.cpp.
Referenced by QDeclarativeAbstractAnimation::setLoops(), QDeclarativeAbstractAnimation::setRunning(), and QDeclarativeAbstractAnimation::timelineComplete().
|
slot |
If paused is true, the animation is paused.
If paused is false, the animation is resumed.
Definition at line 1055 of file qabstractanimation.cpp.
|
slot |
Starts the animation.
The policy argument says whether or not the animation should be deleted when it's done. When the animation starts, the stateChanged() signal is emitted, and state() returns Running. When control reaches the event loop, the animation will run by itself, periodically calling updateCurrentTime() as the animation progresses.
If the animation is currently stopped or has already reached the end, calling start() will rewind the animation and start again from the beginning. When the animation reaches the end, the animation will either stop, or if the loop level is more than 1, it will rewind and continue from the beginning.
If the animation is already running, this function does nothing.
Definition at line 983 of file qabstractanimation.cpp.
Referenced by QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QDeclarativeTimeLinePrivate::add(), QWidgetAnimator::animate(), QParallelAnimationGroupPrivate::applyGroupState(), QStateMachinePrivate::applyProperties(), QDeclarativeTimeLine::remove(), QSmoothedAnimation::restart(), QTabBarPrivate::Tab::startAnimation(), QDeclarativeTimeLine::updateCurrentTime(), and QParallelAnimationGroup::updateState().
State QAbstractAnimation::state | ( | ) | const |
Referenced by QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QParallelAnimationGroupPrivate::applyGroupState(), QTabBarPrivate::moveTabFinished(), QDeclarativeTimeLine::remove(), QSmoothedAnimation::restart(), setDirection(), QParallelAnimationGroup::updateCurrentTime(), QDeclarativeTimeLine::updateCurrentTime(), QParallelAnimationGroup::updateDirection(), QSequentialAnimationGroup::updateDirection(), and ~QAbstractAnimation().
|
signal |
QAbstractAnimation emits this signal whenever the state of the animation has changed from oldState to newState.
This signal is emitted after the virtual updateState() function is called.
Referenced by ~QAbstractAnimation().
|
slot |
Stops the animation.
When the animation is stopped, it emits the stateChanged() signal, and state() returns Stopped. The current time is not changed.
If the animation stops by itself after reaching the end (i.e., currentLoopTime() == duration() and currentLoop() > loopCount() - 1), the finished() signal is emitted.
Definition at line 1002 of file qabstractanimation.cpp.
Referenced by QWidgetAnimator::abort(), QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QDeclarativeTimeLinePrivate::add(), QStateMachinePrivate::applyProperties(), QSmoothedAnimation::init(), QSmoothedAnimation::QSmoothedAnimation(), QDeclarativeTimeLine::remove(), QSequentialAnimationGroupPrivate::setCurrentAnimation(), setCurrentTime(), QDeclarativeAbstractAnimation::setRunning(), QDeclarativeSpringAnimationPrivate::tick(), QParallelAnimationGroup::updateCurrentTime(), QSequentialAnimationGroup::updateCurrentTime(), QDeclarativeTimeLine::updateCurrentTime(), QParallelAnimationGroup::updateState(), QPropertyAnimation::updateState(), and QPropertyAnimation::~QPropertyAnimation().
int QAbstractAnimation::totalDuration | ( | ) | const |
Returns the total and effective duration of the animation, including the loop count.
Definition at line 881 of file qabstractanimation.cpp.
Referenced by QSequentialAnimationGroupPrivate::activateCurrentAnimation(), QSequentialAnimationGroupPrivate::animationActualTotalDuration(), QParallelAnimationGroup::duration(), QSequentialAnimationGroup::duration(), QParallelAnimationGroupPrivate::shouldAnimationStart(), and QParallelAnimationGroup::updateCurrentTime().
|
protectedpure virtual |
This pure virtual function is called every time the animation's currentTime changes.
Implemented in TickAnimationProxy< T, method >, TickAnimationProxy< QDeclarativeParticlesPrivate, &QDeclarativeParticlesPrivate::tick >, QTickAnimationProxy< T, method >, QActionAnimation, QDeclarativeTimeLine, QVariantAnimation, QSmoothedAnimation, QSequentialAnimationGroup, QPauseAnimation, and QParallelAnimationGroup.
Referenced by setCurrentTime().
|
protectedvirtual |
This virtual function is called by QAbstractAnimation when the direction of the animation is changed.
The direction argument is the new direction.
Reimplemented in QSequentialAnimationGroup, and QParallelAnimationGroup.
Definition at line 1103 of file qabstractanimation.cpp.
Referenced by setDirection().
|
protectedvirtual |
This virtual function is called by QAbstractAnimation when the state of the animation is changed from oldState to newState.
Reimplemented in ParallelAnimationWrapper, QVariantAnimation, QSmoothedAnimation, QSequentialAnimationGroup, QPropertyAnimation, and QParallelAnimationGroup.
Definition at line 1090 of file qabstractanimation.cpp.
Referenced by QParallelAnimationGroup::updateState(), and QSequentialAnimationGroup::updateState().
|
private |
the current loop of the animation
This property describes the current loop of the animation. By default, the animation's loop count is 1, and so the current loop will always be 0. If the loop count is 2 and the animation runs past its duration, it will automatically rewind and restart at current time 0, and current loop 1, and so on.
When the current loop changes, QAbstractAnimation emits the currentLoopChanged() signal.
Definition at line 68 of file qabstractanimation.h.
Referenced by QSequentialAnimationGroupPrivate::animationInsertedAt().
|
private |
the current time and progress of the animation
This property describes the animation's current time. You can change the current time by calling setCurrentTime, or you can call start() and let the animation run, setting the current time automatically as the animation progresses.
The animation's current time starts at 0, and ends at totalDuration().
Definition at line 67 of file qabstractanimation.h.
Referenced by QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QSequentialAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), and QSequentialAnimationGroupPrivate::animationInsertedAt().
|
private |
the direction of the animation when it is in Running state.
This direction indicates whether the time moves from 0 towards the animation duration, or from the value of the duration and towards 0 after start() has been called.
By default, this property is set to Forward .
Definition at line 69 of file qabstractanimation.h.
Referenced by QUnifiedTimer::closestPauseAnimationTimeToFinish(), and QUnifiedTimer::updateAnimationsTime().
|
private |
the duration of the animation.
This pure virtual function returns the duration of the animation, and defines for how long QAbstractAnimation should update the current time.
If the duration is -1, it means that the duration is undefined. In this case, loopCount is ignored.
This duration is local, and does not include the loop count.
A return value of -1 indicates that the animation has no defined duration; the animation should run forever until stopped. This is useful for animations that are not time driven, or where you cannot easily predict its duration (e.g., event driven audio playback in a game).
If the animation is a parallel QAnimationGroup, the duration will be the longest duration of all its animations. If the animation is a sequential QAnimationGroup, the duration will be the sum of the duration of all its animations.
Definition at line 70 of file qabstractanimation.h.
Referenced by QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), QUnifiedTimer::closestPauseAnimationTimeToFinish(), and QParallelAnimationGroupPrivate::connectUncontrolledAnimations().
|
private |
the loop count of the animation
This property describes the loop count of the animation as an integer. By default this value is 1, indicating that the animation should run once only, and then stop. By changing it you can let the animation loop several times. With a value of 0, the animation will not run at all, and with a value of -1, the animation will loop forever until stopped. It is not supported to have loop on an animation that has an undefined duration. It will only run once.
Definition at line 66 of file qabstractanimation.h.
Referenced by QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished(), and QParallelAnimationGroupPrivate::connectUncontrolledAnimations().
|
private |
state of the animation.
This property describes the current state of the animation. When the animation state changes, QAbstractAnimation emits the stateChanged() signal.
Definition at line 65 of file qabstractanimation.h.
Referenced by QStateMachinePrivate::applyProperties(), QParallelAnimationGroup::updateCurrentTime(), and QPropertyAnimation::updateState().