QAnimationGroup 类

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 )

额外继承成员

详细描述

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