QAnimationGroup Class
QAnimationGroup クラスは、アニメーションのグループを表す抽象基底クラスです。詳細...
| ヘッダー: | #include <QAnimationGroup> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 継承元: | QAbstractAnimation |
| 継承元: |
- 継承されたメンバーを含む、すべてのメンバーの一覧
- QAnimationGroup はAnimation Framework の一部です。
パブリック関数
| 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) |
再実装されたプロテクト関数
| virtual bool | event(QEvent *event) override |
詳細な説明
アニメーショングループは、アニメーション(QAbstractAnimation のサブクラス)を格納するコンテナです。グループは通常、所属するアニメーションのstate を管理する役割を担います。つまり、アニメーションの開始、停止、再開、一時停止のタイミングを決定します。現在、QtではQParallelAnimationGroup とQSequentialAnimationGroup の2つのグループが提供されています。詳細については、それぞれのクラス説明を参照してください。
QAnimationGroupはQAbstractAnimation を継承しているため、グループを組み合わせることで、複雑なアニメーショングラフを簡単に構築できます。QAbstractAnimation がどのグループに属しているかは、group()関数を使用して問い合わせることができます。
トップレベルのアニメーショングループを開始するには、QAbstractAnimation のstart()関数を使用するだけです。ここでいうトップレベルのアニメーショングループとは、それ自体が他のグループに含まれていないグループを指します。サブグループを直接開始することはサポートされておらず、予期しない動作を引き起こす可能性があります。
QAnimationGroup には、アニメーションを追加および取得するためのメソッドが用意されています。さらに、removeAnimation() を呼び出すことでアニメーションを削除したり、clear() を呼び出すことでアニメーショングループをクリアしたりすることができます。また、QEvent::ChildAdded およびQEvent::ChildRemoved イベントを監視することで、グループ内のアニメーションの変更状況を追跡することも可能です。
QAnimationGroup は、管理するアニメーションの所有権を取得し、アニメーショングループが削除される際にそれらのアニメーションが確実に削除されるようにします。
「 QAbstractAnimation 」、「QVariantAnimation 」、および「アニメーションフレームワーク」も参照してください 。
メンバ関数のドキュメント
QAnimationGroup::QAnimationGroup(QObject *parent = nullptr)
QAnimationGroup を生成します。parent は、QObject のコンストラクタに渡されます。
[virtual noexcept] QAnimationGroup::~QAnimationGroup()
アニメーショングループを削除します。また、そのグループに含まれるすべてのアニメーションも削除されます。
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
このグループにanimation を追加します。これにより、インデックスがanimationCount()となるinsertAnimation が呼び出されます。
注:この グループが アニメーションの所有権を引き継ぎます。
警告:この メソッドは アニメーションのループをチェックしません。追加された `animation ` が、直接的または間接的に `this ` アニメーショングループを含まないことを確認するのは、開発者の責任です。
関連項目: removeAnimation()。
QAbstractAnimation *QAnimationGroup::animationAt(int index) const
このグループ内のindex にあるアニメーションへのポインタを返します。この関数は、特定のアニメーションにアクセスする必要がある場合に便利です。index の値は、0からanimationCount() - 1の範囲です。
animationCount() およびindexOfAnimation()も参照してください 。
int QAnimationGroup::animationCount() const
このグループが管理するアニメーションの数を返します。
indexOfAnimation()、addAnimation()、およびanimationAt()も参照してください 。
void QAnimationGroup::clear()
このアニメーショングループ内のすべてのアニメーションを削除し、現在の時間を 0 にリセットします。
addAnimation() およびremoveAnimation()も参照してください 。
[override virtual protected] bool QAnimationGroup::event(QEvent *event)
QAbstractAnimation::event(QEvent *event) を再実装しています。
int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
animation のインデックスを返します。返されたインデックスは、インデックスを引数として受け取る他の関数に渡すことができます。
insertAnimation()、animationAt()、およびtakeAnimation()も参照してください 。
void QAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
このアニメーショングループのindex の位置に、animation を挿入します。index が0の場合、アニメーションは先頭に挿入されます。index がanimationCount()の場合、アニメーションは末尾に挿入されます。
注:この グループは アニメーションの所有権を引き継ぎます。
警告:この メソッドはアニメーションのループをチェックしません。追加されたanimation が、直接的または間接的にthis のアニメーショングループを含まないことを確認するのは、開発者の責任です。
関連項目: takeAnimation()、addAnimation()、indexOfAnimation()、およびremoveAnimation()。
void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
このグループからanimation を削除します。animation の所有権は呼び出し元に譲渡されます。
takeAnimation()、insertAnimation()、およびaddAnimation()も参照してください 。
QAbstractAnimation *QAnimationGroup::takeAnimation(int index)
index にあるアニメーションを返し、アニメーショングループから削除します。
注: アニメーションの所有権は 呼び出し元に譲渡されます。
関連項目: removeAnimation()、addAnimation()、insertAnimation()、および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.