
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQGraphicsItemAnimation class provides simple animation support forQGraphicsItem.More...
| Header: | #include <QGraphicsItemAnimation> |
| Since: | Qt 4.2 |
| Inherits: | QObject |
This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
| QGraphicsItemAnimation(QObject * parent = 0) | |
| virtual | ~QGraphicsItemAnimation() |
| void | clear() |
| qreal | horizontalScaleAt(qreal step) const |
| qreal | horizontalShearAt(qreal step) const |
| QGraphicsItem * | item() const |
| QMatrix | matrixAt(qreal step) const |
| QPointF | posAt(qreal step) const |
| QList<QPair<qreal, QPointF> > | posList() const |
| qreal | rotationAt(qreal step) const |
| QList<QPair<qreal, qreal> > | rotationList() const |
| QList<QPair<qreal, QPointF> > | scaleList() const |
| void | setItem(QGraphicsItem * item) |
| void | setPosAt(qreal step, const QPointF & point) |
| void | setRotationAt(qreal step, qreal angle) |
| void | setScaleAt(qreal step, qreal sx, qreal sy) |
| void | setShearAt(qreal step, qreal sh, qreal sv) |
| void | setTimeLine(QTimeLine * timeLine) |
| void | setTranslationAt(qreal step, qreal dx, qreal dy) |
| QList<QPair<qreal, QPointF> > | shearList() const |
| QTimeLine * | timeLine() const |
| QList<QPair<qreal, QPointF> > | translationList() const |
| qreal | verticalScaleAt(qreal step) const |
| qreal | verticalShearAt(qreal step) const |
| qreal | xTranslationAt(qreal step) const |
| qreal | yTranslationAt(qreal step) const |
| void | setStep(qreal step) |
| virtual void | afterAnimationStep(qreal step) |
| virtual void | beforeAnimationStep(qreal step) |
TheQGraphicsItemAnimation class provides simple animation support forQGraphicsItem.
TheQGraphicsItemAnimation class animates aQGraphicsItem. You can schedule changes to the item's transformation matrix at specified steps. TheQGraphicsItemAnimation 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 thesetStep() function.
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 aQTimeLine. The timeline'svalueChanged() signal is then connected to thesetStep() slot. For example, you can set up an item for rotation by callingsetRotationAt() for different step values. The animations timeline is set with thesetTimeLine() function.
An example animation with a timeline follows:
QGraphicsItem*ball=newQGraphicsEllipseItem(0,0,20,20);QTimeLine*timer=newQTimeLine(5000); timer->setFrameRange(0,100);QGraphicsItemAnimation*animation=newQGraphicsItemAnimation; animation->setItem(ball); animation->setTimeLine(timer);for (int i=0; i<200;++i) animation->setPosAt(i/200.0,QPointF(i, i));QGraphicsScene*scene=newQGraphicsScene(); scene->setSceneRect(0,0,250,250); scene->addItem(ball);QGraphicsView*view=newQGraphicsView(scene); view->show(); timer->start();
Note that steps lie between 0.0 and 1.0. It may be necessary to usesetUpdateInterval(). 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.
See alsoQTimeLine andGraphics View Framework.
Constructs an animation object with the givenparent.
[virtual]QGraphicsItemAnimation::~QGraphicsItemAnimation()Destroys the animation object.
[virtual protected]void QGraphicsItemAnimation::afterAnimationStep(qreal step)This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place. The animationstep is provided for use in cases where the action depends on its value.
[virtual protected]void QGraphicsItemAnimation::beforeAnimationStep(qreal step)This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. The animationstep is provided for use in cases where the action depends on its value.
Clears the scheduled transformations used for the animation, but retains the item and timeline.
Returns the horizontal scale for the item at the specifiedstep value.
See alsosetScaleAt().
Returns the horizontal shear for the item at the specifiedstep value.
See alsosetShearAt().
Returns the item on which the animation object operates.
See alsosetItem().
Returns the matrix used to transform the item at the specifiedstep value.
Returns the position of the item at the givenstep value.
See alsosetPosAt().
Returns all explicitly inserted positions.
See alsoposAt() andsetPosAt().
Returns the angle at which the item is rotated at the specifiedstep value.
See alsosetRotationAt().
Returns all explicitly inserted rotations.
See alsorotationAt() andsetRotationAt().
Returns all explicitly inserted scales.
See alsoverticalScaleAt(),horizontalScaleAt(), andsetScaleAt().
Sets the specifieditem to be used in the animation.
See alsoitem().
Sets the position of the item at the givenstep value to thepoint specified.
See alsoposAt().
Sets the rotation of the item at the givenstep value to theangle specified.
See alsorotationAt().
Sets the scale of the item at the givenstep value using the horizontal and vertical scale factors specified bysx andsy.
See alsoverticalScaleAt() andhorizontalScaleAt().
Sets the shear of the item at the givenstep value using the horizontal and vertical shear factors specified bysh andsv.
See alsoverticalShearAt() andhorizontalShearAt().
[slot]void QGraphicsItemAnimation::setStep(qreal step)Sets the currentstep value for the animation, causing the transformations scheduled at this step to be performed.
Sets the timeline object used to control the rate of animation to thetimeLine specified.
See alsotimeLine().
Sets the translation of the item at the givenstep value using the horizontal and vertical coordinates specified bydx anddy.
See alsoxTranslationAt() andyTranslationAt().
Returns all explicitly inserted shears.
See alsoverticalShearAt(),horizontalShearAt(), andsetShearAt().
Returns the timeline object used to control the rate at which the animation occurs.
See alsosetTimeLine().
Returns all explicitly inserted translations.
See alsoxTranslationAt(),yTranslationAt(), andsetTranslationAt().
Returns the vertical scale for the item at the specifiedstep value.
See alsosetScaleAt().
Returns the vertical shear for the item at the specifiedstep value.
See alsosetShearAt().
Returns the horizontal translation of the item at the specifiedstep value.
See alsosetTranslationAt().
Returns the vertical translation of the item at the specifiedstep value.
See alsosetTranslationAt().
© 2016 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 theGNU 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.