QAnimationGroup Class
La clase `QAnimationGroup` es una clase base abstracta para grupos de animaciones. Más información...
| Encabezado: | #include <QAnimationGroup> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| Heredado de: | QAbstractAnimation |
| Heredado por: |
- Lista de todos los miembros, incluidos los heredados
- QAnimationGroup forma parte del Marco de animación.
Funciones públicas
| QAnimationGroup(QObject *parent = nullptr) | |
| virtual | ~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) |
Funciones protegidas reimplementadas
| virtual bool | event(QEvent *event) override |
Descripción detallada
Un grupo de animación es un contenedor de animaciones (subclases de ` QAbstractAnimation`). Un grupo suele encargarse de gestionar la « state » de sus animaciones, es decir, decide cuándo iniciarlas, detenerlas, reanudarlas y pausarlas. Actualmente, Qt proporciona dos grupos de este tipo: ` QParallelAnimationGroup ` y ` QSequentialAnimationGroup`. Consulta las descripciones de estas clases para obtener más detalles.
Dado que `QAnimationGroup` hereda de ` QAbstractAnimation`, puedes combinar grupos y construir fácilmente gráficos de animación complejos. Puedes consultar ` QAbstractAnimation ` para saber a qué grupo pertenece (utilizando la función ` group()`).
Para iniciar un grupo de animación de nivel superior, basta con utilizar la función start() de QAbstractAnimation. Por «grupo de animación de nivel superior» nos referimos a un grupo que no está contenido a su vez dentro de otro grupo. No se admite el inicio directo de subgrupos, ya que puede dar lugar a comportamientos inesperados.
QAnimationGroup proporciona métodos para añadir y recuperar animaciones. Además, puedes eliminar animaciones llamando a removeAnimation() y borrar el grupo de animación llamando a clear(). Puedes realizar un seguimiento de los cambios en las animaciones del grupo escuchando los eventos QEvent::ChildAdded y QEvent::ChildRemoved.
QAnimationGroup asume la propiedad de las animaciones que gestiona y garantiza que se eliminen cuando se elimine el grupo de animaciones.
Véase también « QAbstractAnimation », « QVariantAnimation » y «El marco de trabajo de animación».
Documentación de las funciones de miembro
QAnimationGroup::QAnimationGroup(QObject *parent = nullptr)
Crea un objeto `QAnimationGroup`. Se pasa ` parent ` al constructor de ` QObject`.
[virtual noexcept] QAnimationGroup::~QAnimationGroup()
Elimina el grupo de animaciones. También eliminará todas sus animaciones.
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
Añade animation a este grupo. Esto llamará a insertAnimation con un índice igual a animationCount().
Nota: El grupo asume la propiedad de la animación.
Advertencia: Este método no comprueba si hay bucles de animación. Es responsabilidad del desarrollador asegurarse de que el animation añadido no incluya, directa o indirectamente, el grupo de animación this.
Véase también removeAnimation().
QAbstractAnimation *QAnimationGroup::animationAt(int index) const
Devuelve un puntero a la animación que se encuentra en index dentro de este grupo. Esta función resulta útil cuando se necesita acceder a una animación concreta. index está comprendido entre 0 y animationCount() - 1.
Véase también animationCount() y indexOfAnimation().
int QAnimationGroup::animationCount() const
Devuelve el número de animaciones gestionadas por este grupo.
Véase también indexOfAnimation(), addAnimation() y animationAt().
void QAnimationGroup::clear()
Elimina y borra todas las animaciones de este grupo de animación, y restablece la hora actual a 0.
Véase también addAnimation() y removeAnimation().
[override virtual protected] bool QAnimationGroup::event(QEvent *event)
Reimplementa: ` QAbstractAnimation::event(QEvent *event)`.
int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
Devuelve el índice de animation. El índice devuelto se puede pasar a otras funciones que acepten un índice como argumento.
Véase también insertAnimation(), animationAt() y takeAnimation().
void QAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
Inserta « animation » en este grupo de animación en « index ». Si « index » es 0, la animación se inserta al principio. Si « index » es « animationCount()», la animación se inserta al final.
Nota: El grupo asume la propiedad de la animación.
Advertencia: Este método no comprueba si la animación se reproduce en bucle. Es responsabilidad del desarrollador asegurarse de que el animation añadido no incluya, directa o indirectamente, el grupo de animación this.
Véase también takeAnimation(), addAnimation(), indexOfAnimation() y removeAnimation().
void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
Elimina « animation » de este grupo. La titularidad de « animation » se transfiere a quien realiza la llamada.
Véase también takeAnimation(), insertAnimation() y addAnimation().
QAbstractAnimation *QAnimationGroup::takeAnimation(int index)
Devuelve la animación de index y la elimina del grupo de animaciones.
Nota: La propiedad de la animación se transfiere al autor de la llamada.
Véase también removeAnimation(), addAnimation(), insertAnimation() y indexOfAnimation().
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.