QtBase
v6.3.1
|
The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem. More...
#include <qgraphicsitemanimation.h>
Public Slots | |
void | setStep (qreal x) |
Public Slots inherited from QObject | |
void | deleteLater () |
Protected Member Functions | |
virtual void | beforeAnimationStep (qreal step) |
virtual void | afterAnimationStep (qreal step) |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem.
\inmodule QtWidgets
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()
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 a QTimeLine. The timeline's \l{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 setTimeLine() function.
An example animation with a timeline follows:
Note that steps lie between 0.0 and 1.0. It may be necessary to use \l{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.
Definition at line 56 of file qgraphicsitemanimation.h.
Constructs an animation object with the given parent.
Definition at line 193 of file qgraphicsitemanimation.cpp.
|
virtual |
Destroys the animation object.
Definition at line 202 of file qgraphicsitemanimation.cpp.
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.
Definition at line 576 of file qgraphicsitemanimation.cpp.
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.
Definition at line 563 of file qgraphicsitemanimation.cpp.
void QGraphicsItemAnimation::clear | ( | ) |
Clears the scheduled transformations used for the animation, but retains the item and timeline.
Definition at line 511 of file qgraphicsitemanimation.cpp.
Returns the horizontal scale for the item at the specified step value.
Definition at line 423 of file qgraphicsitemanimation.cpp.
Returns the horizontal shear for the item at the specified step value.
Definition at line 473 of file qgraphicsitemanimation.cpp.
QGraphicsItem * QGraphicsItemAnimation::item | ( | ) | const |
Returns the item on which the animation object operates.
Definition at line 212 of file qgraphicsitemanimation.cpp.
Returns the position of the item at the given step value.
Definition at line 262 of file qgraphicsitemanimation.cpp.
Returns all explicitly inserted positions.
Definition at line 287 of file qgraphicsitemanimation.cpp.
Returns the angle at which the item is rotated at the specified step value.
Definition at line 324 of file qgraphicsitemanimation.cpp.
Returns all explicitly inserted rotations.
Definition at line 345 of file qgraphicsitemanimation.cpp.
Returns all explicitly inserted scales.
Definition at line 446 of file qgraphicsitemanimation.cpp.
void QGraphicsItemAnimation::setItem | ( | QGraphicsItem * | item | ) |
Sets the specified item to be used in the animation.
Definition at line 222 of file qgraphicsitemanimation.cpp.
Sets the position of the item at the given step value to the point specified.
Definition at line 276 of file qgraphicsitemanimation.cpp.
Sets the rotation of the item at the given step value to the angle specified.
Definition at line 335 of file qgraphicsitemanimation.cpp.
Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy.
Definition at line 435 of file qgraphicsitemanimation.cpp.
Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv.
Definition at line 485 of file qgraphicsitemanimation.cpp.
Sets the current step value for the animation, causing the transformations scheduled at this step to be performed.
Definition at line 530 of file qgraphicsitemanimation.cpp.
Sets the timeline object used to control the rate of animation to the timeLine specified.
Definition at line 245 of file qgraphicsitemanimation.cpp.
Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy.
Definition at line 384 of file qgraphicsitemanimation.cpp.
Returns all explicitly inserted shears.
Definition at line 496 of file qgraphicsitemanimation.cpp.
QTimeLine * QGraphicsItemAnimation::timeLine | ( | ) | const |
Returns the timeline object used to control the rate at which the animation occurs.
Definition at line 234 of file qgraphicsitemanimation.cpp.
QTransform QGraphicsItemAnimation::transformAt | ( | qreal | step | ) | const |
Returns the transform used for the item at the specified step value.
Definition at line 303 of file qgraphicsitemanimation.cpp.
Returns all explicitly inserted translations.
Definition at line 395 of file qgraphicsitemanimation.cpp.
Returns the vertical scale for the item at the specified step value.
Definition at line 411 of file qgraphicsitemanimation.cpp.
Returns the vertical shear for the item at the specified step value.
Definition at line 462 of file qgraphicsitemanimation.cpp.
Returns the horizontal translation of the item at the specified step value.
Definition at line 361 of file qgraphicsitemanimation.cpp.
Returns the vertical translation of the item at the specified step value.
Definition at line 372 of file qgraphicsitemanimation.cpp.