QAnimationGroup Class
The QAnimationGroup class is an abstract base class for groups of animations. More…
| Header | #include <QAnimationGroup> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 4.6 |
| Inherits | QAbstractAnimation |
| Inherited by | QParallelAnimationGroup, QSequentialAnimationGroup |
List of all members, including inherited members
Public Functions
| QAnimationGroup(QObject *parent = nullptr) | |
| ~QAnimationGroup() | |
| QAbstractAnimation * | animationAt(int index) const |
| int | animationCount() const |
| int | indexOfAnimation(QAbstractAnimation *animation) const |
| void | addAnimation(QAbstractAnimation *animation) |
| void | insertAnimation(int index, QAbstractAnimation *animation) |
| void | removeAnimation(QAbstractAnimation *animation) |
| QAbstractAnimation * | takeAnimation(int index) |
| void | clear() |
Reimplemented Protected Functions
Detailed Description
A group is an animation that holds other animations and runs them: one after another in a QSequentialAnimationGroup, all together in a QParallelAnimationGroup. The program starts, pauses and stops the group, and the group does the same with what it holds. As a group is an animation, groups can hold groups.
auto *group = new QSequentialAnimationGroup;
group->addAnimation(new QPropertyAnimation(panel, "pos"));
group->addPause(200);
group->addAnimation(new QPropertyAnimation(panel, "size"));
group->start(QAbstractAnimation::DeleteWhenStopped);
The group owns its animations: it becomes their parent and deletes them when it is deleted.
See also QSequentialAnimationGroup and QParallelAnimationGroup.
Differences from Qt
None.
Member Function Documentation
QAnimationGroup::QAnimationGroup(QObject *parent = nullptr)
Constructs a group with the given parent.
QAnimationGroup::~QAnimationGroup()
Destroys the group and the animations in it.
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
Adds animation at the end of the group, which takes ownership of it. An animation that is in another group is taken out of that one.
See also insertAnimation() and removeAnimation().
QAbstractAnimation * QAnimationGroup::animationAt(int index) const
Returns the animation at index, which must be at least 0 and less than animationCount().
See also animationCount() and indexOfAnimation().
int QAnimationGroup::animationCount() const
Returns the number of animations in the group.
See also animationAt().
void QAnimationGroup::clear()
Takes every animation out of the group and deletes it.
See also takeAnimation().
bool QAnimationGroup::event(QEvent *event)
Reimplements QAbstractAnimation::event().
int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
Returns the index of animation in the group, or -1 if it is not in it.
See also animationAt().
void QAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
Inserts animation into the group at index, which is 0 for the front and animationCount() for the end. The group takes ownership of the animation.
See also addAnimation() and takeAnimation().
void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
Takes animation out of the group. The caller owns it afterwards: it has no parent.
See also takeAnimation() and addAnimation().
QAbstractAnimation * QAnimationGroup::takeAnimation(int index)
Takes the animation at index out of the group and returns it. The caller owns it afterwards: it has no parent. A group that runs and has no animation left stops.
See also removeAnimation() and clear().