Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QGraphicsItemAnimation Class

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.

Public Functions

QGraphicsItemAnimation(QObject * parent = 0)
virtual~QGraphicsItemAnimation()
voidclear()
qrealhorizontalScaleAt(qreal step) const
qrealhorizontalShearAt(qreal step) const
QGraphicsItem *item() const
QMatrixmatrixAt(qreal step) const
QPointFposAt(qreal step) const
QList<QPair<qreal, QPointF> >posList() const
qrealrotationAt(qreal step) const
QList<QPair<qreal, qreal> >rotationList() const
QList<QPair<qreal, QPointF> >scaleList() const
voidsetItem(QGraphicsItem * item)
voidsetPosAt(qreal step, const QPointF & point)
voidsetRotationAt(qreal step, qreal angle)
voidsetScaleAt(qreal step, qreal sx, qreal sy)
voidsetShearAt(qreal step, qreal sh, qreal sv)
voidsetTimeLine(QTimeLine * timeLine)
voidsetTranslationAt(qreal step, qreal dx, qreal dy)
QList<QPair<qreal, QPointF> >shearList() const
QTimeLine *timeLine() const
QList<QPair<qreal, QPointF> >translationList() const
qrealverticalScaleAt(qreal step) const
qrealverticalShearAt(qreal step) const
qrealxTranslationAt(qreal step) const
qrealyTranslationAt(qreal step) const
  • 29 public functions inherited fromQObject

Public Slots

voidsetStep(qreal step)
  • 1 public slot inherited fromQObject

Protected Functions

virtual voidafterAnimationStep(qreal step)
virtual voidbeforeAnimationStep(qreal step)
  • 8 protected functions inherited fromQObject

Additional Inherited Members

  • 1 property inherited fromQObject
  • 1 signal inherited fromQObject
  • 7 static public members inherited fromQObject

Detailed Description

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.

Member Function Documentation

QGraphicsItemAnimation::QGraphicsItemAnimation(QObject * parent = 0)

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.

void QGraphicsItemAnimation::clear()

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

qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const

Returns the horizontal scale for the item at the specifiedstep value.

See alsosetScaleAt().

qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const

Returns the horizontal shear for the item at the specifiedstep value.

See alsosetShearAt().

QGraphicsItem * QGraphicsItemAnimation::item() const

Returns the item on which the animation object operates.

See alsosetItem().

QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const

Returns the matrix used to transform the item at the specifiedstep value.

QPointF QGraphicsItemAnimation::posAt(qreal step) const

Returns the position of the item at the givenstep value.

See alsosetPosAt().

QList<QPair<qreal,QPointF> > QGraphicsItemAnimation::posList() const

Returns all explicitly inserted positions.

See alsoposAt() andsetPosAt().

qreal QGraphicsItemAnimation::rotationAt(qreal step) const

Returns the angle at which the item is rotated at the specifiedstep value.

See alsosetRotationAt().

QList<QPair<qreal,qreal> > QGraphicsItemAnimation::rotationList() const

Returns all explicitly inserted rotations.

See alsorotationAt() andsetRotationAt().

QList<QPair<qreal,QPointF> > QGraphicsItemAnimation::scaleList() const

Returns all explicitly inserted scales.

See alsoverticalScaleAt(),horizontalScaleAt(), andsetScaleAt().

void QGraphicsItemAnimation::setItem(QGraphicsItem * item)

Sets the specifieditem to be used in the animation.

See alsoitem().

void QGraphicsItemAnimation::setPosAt(qreal step, constQPointF & point)

Sets the position of the item at the givenstep value to thepoint specified.

See alsoposAt().

void QGraphicsItemAnimation::setRotationAt(qreal step,qreal angle)

Sets the rotation of the item at the givenstep value to theangle specified.

See alsorotationAt().

void QGraphicsItemAnimation::setScaleAt(qreal step,qreal sx,qreal sy)

Sets the scale of the item at the givenstep value using the horizontal and vertical scale factors specified bysx andsy.

See alsoverticalScaleAt() andhorizontalScaleAt().

void QGraphicsItemAnimation::setShearAt(qreal step,qreal sh,qreal sv)

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.

void QGraphicsItemAnimation::setTimeLine(QTimeLine * timeLine)

Sets the timeline object used to control the rate of animation to thetimeLine specified.

See alsotimeLine().

void QGraphicsItemAnimation::setTranslationAt(qreal step,qreal dx,qreal dy)

Sets the translation of the item at the givenstep value using the horizontal and vertical coordinates specified bydx anddy.

See alsoxTranslationAt() andyTranslationAt().

QList<QPair<qreal,QPointF> > QGraphicsItemAnimation::shearList() const

Returns all explicitly inserted shears.

See alsoverticalShearAt(),horizontalShearAt(), andsetShearAt().

QTimeLine * QGraphicsItemAnimation::timeLine() const

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

See alsosetTimeLine().

QList<QPair<qreal,QPointF> > QGraphicsItemAnimation::translationList() const

Returns all explicitly inserted translations.

See alsoxTranslationAt(),yTranslationAt(), andsetTranslationAt().

qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const

Returns the vertical scale for the item at the specifiedstep value.

See alsosetScaleAt().

qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const

Returns the vertical shear for the item at the specifiedstep value.

See alsosetShearAt().

qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const

Returns the horizontal translation of the item at the specifiedstep value.

See alsosetTranslationAt().

qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const

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.


[8]ページ先頭

©2009-2025 Movatter.jp