QGraphicsItemAnimation Class Reference

[ QtGui module]

The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem . 更多...

继承 QObject .

方法


详细描述

The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem .

The QGraphicsItemAnimation class animates a QGraphicsItem . You can schedule changes to the item's transformation matrix at specified steps. The 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() 函数。

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 QTimeLine . The timeline's 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 setTimeLine () 函数。

An example animation with a timeline follows:

     QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
     QTimeLine *timer = new QTimeLine(5000);
     timer->setFrameRange(0, 100);
     QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
     animation->setItem(ball);
     animation->setTimeLine(timer);
     for (int i = 0; i < 200; ++i)
         animation->setPosAt(i / 200.0, QPointF(i, i));
     QGraphicsScene *scene = new QGraphicsScene();
     scene->setSceneRect(0, 0, 250, 250);
     scene->addItem(ball);
     QGraphicsView *view = new QGraphicsView(scene);
     view->show();
     timer->start();
			

Note that steps lie between 0.0 and 1.0. It may be necessary to use setUpdateInterval() 。 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.


方法文档编制

QGraphicsItemAnimation.__init__ ( self , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an animation object with the given parent .

QGraphicsItemAnimation.afterAnimationStep ( self , float  step )

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.

QGraphicsItemAnimation.beforeAnimationStep ( self , float  step )

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.

QGraphicsItemAnimation.clear ( self )

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

float QGraphicsItemAnimation.horizontalScaleAt ( self , float  step )

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

另请参阅 setScaleAt ().

float QGraphicsItemAnimation.horizontalShearAt ( self , float  step )

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

另请参阅 setShearAt ().

QGraphicsItem QGraphicsItemAnimation.item ( self )

Returns the item on which the animation object operates.

另请参阅 setItem ().

QMatrix QGraphicsItemAnimation.matrixAt ( self , float  step )

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

QPointF QGraphicsItemAnimation.posAt ( self , float  step )

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

另请参阅 setPosAt ().

list-of-tuple-of-float-QPointF QGraphicsItemAnimation.posList ( self )

Returns all explicitly inserted positions.

另请参阅 posAt () 和 setPosAt ().

QGraphicsItemAnimation.reset ( self )

This method is also a Qt slot with the C++ signature void reset() .

float QGraphicsItemAnimation.rotationAt ( self , float  step )

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

另请参阅 setRotationAt ().

list-of-tuple-of-float-float QGraphicsItemAnimation.rotationList ( self )

Returns all explicitly inserted rotations.

另请参阅 rotationAt () 和 setRotationAt ().

list-of-tuple-of-float-QPointF QGraphicsItemAnimation.scaleList ( self )

Returns all explicitly inserted scales.

另请参阅 verticalScaleAt (), horizontalScaleAt (), and setScaleAt ().

QGraphicsItemAnimation.setItem ( self , QGraphicsItem   item )

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

另请参阅 item ().

QGraphicsItemAnimation.setPosAt ( self , float  step , QPointF   pos )

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

另请参阅 posAt ().

QGraphicsItemAnimation.setRotationAt ( self , float  step , float  angle )

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

另请参阅 rotationAt ().

QGraphicsItemAnimation.setScaleAt ( self , float  step , float  sx , float  sy )

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

另请参阅 verticalScaleAt () and horizontalScaleAt ().

QGraphicsItemAnimation.setShearAt ( self , float  step , float  sh , float  sv )

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

另请参阅 verticalShearAt () and horizontalShearAt ().

QGraphicsItemAnimation.setStep ( self , float  x )

This method is also a Qt slot with the C++ signature void setStep(qreal) .

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

QGraphicsItemAnimation.setTimeLine ( self , QTimeLine   timeLine )

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

另请参阅 timeLine ().

QGraphicsItemAnimation.setTranslationAt ( self , float  step , float  dx , float  dy )

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

另请参阅 xTranslationAt () and yTranslationAt ().

list-of-tuple-of-float-QPointF QGraphicsItemAnimation.shearList ( self )

Returns all explicitly inserted shears.

另请参阅 verticalShearAt (), horizontalShearAt (), and setShearAt ().

QTimeLine QGraphicsItemAnimation.timeLine ( self )

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

另请参阅 setTimeLine ().

list-of-tuple-of-float-QPointF QGraphicsItemAnimation.translationList ( self )

Returns all explicitly inserted translations.

另请参阅 xTranslationAt (), yTranslationAt (), and setTranslationAt ().

float QGraphicsItemAnimation.verticalScaleAt ( self , float  step )

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

另请参阅 setScaleAt ().

float QGraphicsItemAnimation.verticalShearAt ( self , float  step )

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

另请参阅 setShearAt ().

float QGraphicsItemAnimation.xTranslationAt ( self , float  step )

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

另请参阅 setTranslationAt ().

float QGraphicsItemAnimation.yTranslationAt ( self , float  step )

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

另请参阅 setTranslationAt ().