• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QGraphicsScene

    下一话题

    QDataWidgetMapper

    QGraphicsItemAnimation

    概要

    函数

    虚函数

    详细描述

    PySide.QtGui.QGraphicsItemAnimation class provides simple animation support for PySide.QtGui.QGraphicsItem .

    PySide.QtGui.QGraphicsItemAnimation class animates a PySide.QtGui.QGraphicsItem . You can schedule changes to the item's transformation matrix at specified steps. The PySide.QtGui.QGraphicsItemAnimation class has a current step value. When this value changes the transformations scheduled at that step are performed. The current step of the animation is set with the setStep() 函数。

    PySide.QtGui.QGraphicsItemAnimation will do a simple linear interpolation between the nearest adjacent scheduled changes to calculate the matrix. For instance, if you set the position of an item at values 0.0 and 1.0, the animation will show the item moving in a straight line between these positions. The same is true for scaling and rotation.

    It is usual to use the class with a PySide.QtCore.QTimeLine . The timeline's PySide.QtCore.QTimeLine.valueChanged() signal is then connected to the setStep() slot. For example, you can set up an item for rotation by calling setRotationAt() for different step values. The animations timeline is set with the PySide.QtGui.QGraphicsItemAnimation.setTimeLine() 函数。

    An example animation with a timeline follows:

    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(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()
    										

    Note that steps lie between 0.0 and 1.0. It may be necessary to use PySide.QtCore.QTimeLine.setUpdateInterval() . The default update interval is 40 ms. A scheduled transformation cannot be removed when set, so scheduling several transformations of the same kind (e.g., rotations) at the same step is not recommended.

    另请参阅

    PySide.QtCore.QTimeLine 图形视图框架

    class PySide.QtGui. QGraphicsItemAnimation ( [ parent=None ] )
    参数: parent PySide.QtCore.QObject

    Constructs an animation object with the given parent .

    PySide.QtGui.QGraphicsItemAnimation. afterAnimationStep ( step )
    参数: step PySide.QtCore.qreal

    This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place. The animation step is provided for use in cases where the action depends on its value.

    PySide.QtGui.QGraphicsItemAnimation. beforeAnimationStep ( step )
    参数: step PySide.QtCore.qreal

    This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. The animation step is provided for use in cases where the action depends on its value.

    PySide.QtGui.QGraphicsItemAnimation. clear ( )

    Clears the scheduled transformations used for the animation, but retains the item and timeline.

    PySide.QtGui.QGraphicsItemAnimation. horizontalScaleAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the horizontal scale for the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. horizontalShearAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the horizontal shear for the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. item ( )
    返回类型: PySide.QtGui.QGraphicsItem

    Returns the item on which the animation object operates.

    PySide.QtGui.QGraphicsItemAnimation. matrixAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtGui.QMatrix

    Returns the matrix used to transform the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. posAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.QPointF

    Returns the position of the item at the given step 值。

    PySide.QtGui.QGraphicsItemAnimation. posList ( )
    返回类型:

    Returns all explicitly inserted positions.

    PySide.QtGui.QGraphicsItemAnimation. reset ( )

    Resets the item to its starting position and transformation.

    You can call setStep(0) instead.

    PySide.QtGui.QGraphicsItemAnimation. rotationAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the angle at which the item is rotated at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. rotationList ( )
    返回类型:

    Returns all explicitly inserted rotations.

    PySide.QtGui.QGraphicsItemAnimation. scaleList ( )
    返回类型:

    Returns all explicitly inserted scales.

    PySide.QtGui.QGraphicsItemAnimation. setItem ( item )
    参数: item PySide.QtGui.QGraphicsItem

    设置指定 item to be used in the animation.

    PySide.QtGui.QGraphicsItemAnimation. setPosAt ( step , pos )
    参数:

    Sets the position of the item at the given step value to the point 指定。

    PySide.QtGui.QGraphicsItemAnimation. setRotationAt ( step , angle )
    参数:
    • step PySide.QtCore.qreal
    • angle PySide.QtCore.qreal

    Sets the rotation of the item at the given step value to the angle 指定。

    PySide.QtGui.QGraphicsItemAnimation. setScaleAt ( step , sx , sy )
    参数:
    • step PySide.QtCore.qreal
    • sx PySide.QtCore.qreal
    • sy PySide.QtCore.qreal

    Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy .

    PySide.QtGui.QGraphicsItemAnimation. setShearAt ( step , sh , sv )
    参数:
    • step PySide.QtCore.qreal
    • sh PySide.QtCore.qreal
    • sv PySide.QtCore.qreal

    Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv .

    PySide.QtGui.QGraphicsItemAnimation. setStep ( x )
    参数: x PySide.QtCore.qreal

    设置当前 step value for the animation, causing the transformations scheduled at this step to be performed.

    PySide.QtGui.QGraphicsItemAnimation. setTimeLine ( timeLine )
    参数: timeLine PySide.QtCore.QTimeLine

    Sets the timeline object used to control the rate of animation to the timeLine 指定。

    PySide.QtGui.QGraphicsItemAnimation. setTranslationAt ( step , dx , dy )
    参数:
    • step PySide.QtCore.qreal
    • dx PySide.QtCore.qreal
    • dy PySide.QtCore.qreal

    Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy .

    PySide.QtGui.QGraphicsItemAnimation. shearList ( )
    返回类型:

    Returns all explicitly inserted shears.

    PySide.QtGui.QGraphicsItemAnimation. timeLine ( )
    返回类型: PySide.QtCore.QTimeLine

    Returns the timeline object used to control the rate at which the animation occurs.

    PySide.QtGui.QGraphicsItemAnimation. translationList ( )
    返回类型:

    Returns all explicitly inserted translations.

    PySide.QtGui.QGraphicsItemAnimation. verticalScaleAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the vertical scale for the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. verticalShearAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the vertical shear for the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. xTranslationAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the horizontal translation of the item at the specified step 值。

    PySide.QtGui.QGraphicsItemAnimation. yTranslationAt ( step )
    参数: step PySide.QtCore.qreal
    返回类型: PySide.QtCore.qreal

    Returns the vertical translation of the item at the specified step 值。