PySide6.QtWidgets.QGraphicsItemAnimation¶
- class QGraphicsItemAnimation¶
QGraphicsItemAnimation类为QGraphicsItem提供了简单的动画支持。更多…概要¶
方法¶
def
__init__()def
clear()def
item()def
posAt()def
posList()def
rotationAt()def
rotationList()def
scaleList()def
setItem()def
setPosAt()def
setRotationAt()def
setScaleAt()def
setShearAt()def
setTimeLine()def
shearList()def
timeLine()def
transformAt()def
xTranslationAt()def
yTranslationAt()
虚拟方法¶
插槽¶
def
setStep()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
QGraphicsItemAnimation类用于动画化一个QGraphicsItem。你可以在指定的步骤中安排项目变换矩阵的更改。QGraphicsItemAnimation类有一个当前步骤值。当这个值改变时,该步骤中安排的变换将被执行。动画的当前步骤通过setStep()函数设置。QGraphicsItemAnimation将在最近的相邻预定变化之间进行简单的线性插值来计算矩阵。例如,如果您在值 0.0 和 1.0 处设置项目的位置,动画将显示项目在这些位置之间沿直线移动。缩放和旋转也是如此。通常与QTimeLine一起使用该类。然后将时间轴的valueChanged()信号连接到
setStep()槽。例如,您可以通过为不同的步骤值调用setRotationAt()来设置一个旋转项目。动画时间轴通过setTimeLine()函数设置。以下是一个带有时间轴的动画示例:
ball = QGraphicsEllipseItem(0, 0, 20, 20) timer = QTimeLine(5000) timer.setFrameRange(0, 100) animation = QGraphicsItemAnimation() animation.setItem(ball) animation.setTimeLine(timer) for i in range(0, 200): animation.setPosAt(i / 200.0, QPointF(i, i)) scene = QGraphicsScene() scene.setSceneRect(0, 0, 250, 250) scene.addItem(ball) view = QGraphicsView(scene) view.show() timer.start()
请注意,步骤介于0.0和1.0之间。可能需要使用setUpdateInterval()。默认的更新间隔是40毫秒。当设置时,预定的转换无法移除,因此不建议在同一步骤中安排多个相同类型的转换(例如,旋转)。
另请参阅
使用给定的
parent构建一个动画对象。- afterAnimationStep(step)¶
- Parameters:
步长 – 浮点数
此方法旨在在子类中被重写,这些子类需要在新步骤发生后执行额外的代码。动画
step用于在动作依赖于其值的情况下使用。- beforeAnimationStep(step)¶
- Parameters:
步长 – 浮点数
此方法旨在被子类重写,这些子类需要在新步骤发生之前执行额外的代码。动画
step在动作依赖于其值的情况下提供使用。- clear()¶
清除用于动画的预定变换,但保留项目和时间线。
- horizontalScaleAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值处项目的水平比例。另请参阅
- horizontalShearAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值处项目的水平剪切。另请参阅
- item()¶
- Return type:
返回动画对象操作的项目。
另请参阅
返回给定
step值处项目的位置。另请参阅
返回所有显式插入的位置。
另请参阅
- rotationAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回项目在指定的
step值处旋转的角度。另请参阅
- rotationList()¶
- Return type:
.std.pairqreal,qreal的列表
返回所有显式插入的旋转。
返回所有显式插入的比例尺。
- setItem(item)¶
- Parameters:
项目 –
QGraphicsItem
设置指定的
item用于动画中。另请参阅
将给定
step值的项目位置设置为指定的point。另请参阅
- setRotationAt(step, angle)¶
- Parameters:
step – 浮点数
angle – 浮点数
将给定
step值的项目旋转到指定的angle。另请参阅
- setScaleAt(step, sx, sy)¶
- Parameters:
step – 浮点数
sx – 浮点数
sy – 浮点数
使用由
sx和sy指定的水平和垂直比例因子,在给定的step值处设置项目的比例。- setShearAt(step, sh, sv)¶
- Parameters:
step – 浮点数
sh – 浮点数
sv – 浮点数
使用由
sh和sv指定的水平和垂直剪切因子,在给定的step值处设置项目的剪切。- setStep(x)¶
- Parameters:
x – 浮点数
设置动画的当前
step值,导致在此步骤安排的转换被执行。将用于控制动画速率的时间线对象设置为指定的
timeLine。另请参阅
- setTranslationAt(step, dx, dy)¶
- Parameters:
step – 浮点数
dx – 浮点数
dy – 浮点数
使用由
dx和dy指定的水平和垂直坐标,设置给定step值处项目的平移。返回所有显式插入的剪切。
返回用于控制动画发生速率的时间线对象。
另请参阅
- transformAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
返回用于指定
step值的项目的变换。返回所有明确插入的翻译。
- verticalScaleAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值处项目的垂直比例。另请参阅
- verticalShearAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值的项目的垂直剪切。另请参阅
- xTranslationAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值处项目的水平平移。另请参阅
- yTranslationAt(step)¶
- Parameters:
步长 – 浮点数
- Return type:
浮点数
返回指定
step值处项目的垂直平移。另请参阅