PySide6.QtCore.QAnimationGroup¶
- class QAnimationGroup¶
QAnimationGroup
类是动画组的抽象基类。更多…继承者:
QSequentialAnimationGroup
,QParallelAnimationGroup
在版本4.6中添加。
概要¶
方法¶
def
__init__()
def
addAnimation()
def
animationAt()
def
animationCount()
def
clear()
def
takeAnimation()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
动画组是动画的容器(
QAbstractAnimation
的子类)。一个组通常负责管理其动画的state
,即决定何时开始、停止、恢复和暂停它们。目前,Qt 提供了两个这样的组:QParallelAnimationGroup
和QSequentialAnimationGroup
。查看它们的类描述以获取详细信息。由于
QAnimationGroup
继承自QAbstractAnimation
,你可以组合多个组,并轻松构建复杂的动画图。你可以查询QAbstractAnimation
以了解它所属的组(使用group()
函数)。要启动一个顶级动画组,您只需使用
start()
函数从QAbstractAnimation
中。所谓顶级动画组,我们指的是一个本身不包含在其他组中的组。直接启动子组是不支持的,可能会导致意外行为。QAnimationGroup
提供了添加和检索动画的方法。除此之外,您可以通过调用removeAnimation()
来移除动画,并通过调用clear()
来清除动画组。您可以通过监听ChildAdded
和ChildRemoved
事件来跟踪组中动画的变化。QAnimationGroup
拥有其管理的动画的所有权,并确保在动画组被删除时这些动画也会被删除。构造一个
QAnimationGroup
。parent
被传递给QObject
的构造函数。- addAnimation(animation)¶
- Parameters:
动画 –
QAbstractAnimation
向此组添加
animation
。这将调用insertAnimation
,索引等于animationCount()
。- animationAt(index)¶
- Parameters:
索引 – int
- Return type:
返回指向此组中
index
处动画的指针。当您需要访问特定动画时,此函数非常有用。index
介于0和animationCount()
- 1之间。- animationCount()¶
- Return type:
整数
返回此组管理的动画数量。
- clear()¶
移除并删除此动画组中的所有动画,并将当前时间重置为0。
- indexOfAnimation(animation)¶
- Parameters:
动画 –
QAbstractAnimation
- Return type:
整数
返回
animation
的索引。返回的索引可以作为参数传递给其他接受索引的函数。- insertAnimation(index, animation)¶
- Parameters:
index – 整数
animation –
QAbstractAnimation
将
animation
插入到此动画组中的index
位置。如果index
为0,则动画插入到开头。如果index
为animationCount()
,则动画插入到末尾。- removeAnimation(animation)¶
- Parameters:
动画 –
QAbstractAnimation
从该组中移除
animation
。animation
的所有权将转移给调用者。- takeAnimation(index)¶
- Parameters:
索引 – int
- Return type:
返回位于
index
的动画并将其从动画组中移除。