QAnimationGroup 類

The QAnimationGroup class is an abstract base class for groups of animations. 更多...

頭: #include <QAnimationGroup>
qmake: QT += core
Since: Qt 4.6
繼承: QAbstractAnimation
繼承者: QParallelAnimationGroup and QSequentialAnimationGroup

公共函數

QAnimationGroup (QObject * parent = Q_NULLPTR)
~QAnimationGroup ()
void addAnimation (QAbstractAnimation * animation )
QAbstractAnimation * animationAt (int index ) const
int animationCount () const
void clear ()
int indexOfAnimation (QAbstractAnimation * animation ) const
void insertAnimation (int index , QAbstractAnimation * animation )
void removeAnimation (QAbstractAnimation * animation )
QAbstractAnimation * takeAnimation (int index )

重實現保護函數

virtual bool event (QEvent * event )

額外繼承成員

詳細描述

The QAnimationGroup class is an abstract base class for groups of animations.

An animation group is a container for animations (subclasses of QAbstractAnimation ). A group is usually responsible for managing the state of its animations, i.e., it decides when to start, stop, resume, and pause them. Currently, Qt provides two such groups: QParallelAnimationGroup and QSequentialAnimationGroup . Look up their class descriptions for details.

由於 QAnimationGroup 繼承自 QAbstractAnimation , you can combine groups, and easily construct complex animation graphs. You can query QAbstractAnimation for the group it belongs to (using the group() 函數)。

To start a top-level animation group, you simply use the start() function from QAbstractAnimation . By a top-level animation group, we think of a group that itself is not contained within another group. Starting sub groups directly is not supported, and may lead to unexpected behavior.

QAnimationGroup provides methods for adding and retrieving animations. Besides that, you can remove animations by calling removeAnimation (), and clear the animation group by calling clear (). You may keep track of changes in the group's animations by listening to QEvent::ChildAdded and QEvent::ChildRemoved 事件。

QAnimationGroup takes ownership of the animations it manages, and ensures that they are deleted when the animation group is deleted.

另請參閱 QAbstractAnimation , QVariantAnimation ,和 動畫框架 .

成員函數文檔編製

QAnimationGroup:: QAnimationGroup ( QObject * parent = Q_NULLPTR)

構造 QAnimationGroup . parent 被傳遞給 QObject 的構造函數。

QAnimationGroup:: ~QAnimationGroup ()

Destroys the animation group. It will also destroy all its animations.

void QAnimationGroup:: addAnimation ( QAbstractAnimation * animation )

添加 animation to this group. This will call insertAnimation with index equals to animationCount ().

注意: The group takes ownership of the animation.

另請參閱 removeAnimation ().

QAbstractAnimation *QAnimationGroup:: animationAt ( int index ) const

Returns a pointer to the animation at index in this group. This function is useful when you need access to a particular animation. index is between 0 and animationCount () - 1.

另請參閱 animationCount () 和 indexOfAnimation ().

int QAnimationGroup:: animationCount () const

Returns the number of animations managed by this group.

另請參閱 indexOfAnimation (), addAnimation (),和 animationAt ().

void QAnimationGroup:: clear ()

Removes and deletes all animations in this animation group, and resets the current time to 0.

另請參閱 addAnimation () 和 removeAnimation ().

[virtual protected] bool QAnimationGroup:: event ( QEvent * event )

重實現自 QObject::event ().

int QAnimationGroup:: indexOfAnimation ( QAbstractAnimation * animation ) const

返迴索引對於 animation . The returned index can be passed to the other functions that take an index as an argument.

另請參閱 insertAnimation (), animationAt (),和 takeAnimation ().

void QAnimationGroup:: insertAnimation ( int index , QAbstractAnimation * animation )

插入 animation into this animation group at index 。若 index is 0 the animation is inserted at the beginning. If index is animationCount (), the animation is inserted at the end.

注意: The group takes ownership of the animation.

另請參閱 takeAnimation (), addAnimation (), indexOfAnimation (),和 removeAnimation ().

void QAnimationGroup:: removeAnimation ( QAbstractAnimation * animation )

移除 animation from this group. The ownership of animation is transferred to the caller.

另請參閱 takeAnimation (), insertAnimation (),和 addAnimation ().

QAbstractAnimation *QAnimationGroup:: takeAnimation ( int index )

Returns the animation at index and removes it from the animation group.

注意: The ownership of the animation is transferred to the caller.

另請參閱 removeAnimation (), addAnimation (), insertAnimation (),和 indexOfAnimation ().