Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QGraphicsItemAnimation Class Reference
[QtGui module]

The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem. More...

 #include <QGraphicsItemAnimation>

Inherits QObject.

This class was introduced in Qt 4.2.

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • 1 public slot inherited from QObject

Protected Functions

  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject

Detailed Description

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

     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(). 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 also QTimeLine and The Graphics View Framework.


Member Function Documentation

QGraphicsItemAnimation::QGraphicsItemAnimation ( QObject * parent = 0 )

Constructs an animation object with the given parent.

QGraphicsItemAnimation::~QGraphicsItemAnimation ()   [virtual]

Destroys the animation object.

void QGraphicsItemAnimation::afterAnimationStep ( qreal step )   [virtual protected]

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.

void QGraphicsItemAnimation::beforeAnimationStep ( qreal step )   [virtual protected]

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.

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 specified step value.

See also setScaleAt().

qreal QGraphicsItemAnimation::horizontalShearAt ( qreal step ) const

Returns the horizontal shear for the item at the specified step value.

See also setShearAt().

QGraphicsItem * QGraphicsItemAnimation::item () const

Returns the item on which the animation object operates.

See also setItem().

QMatrix QGraphicsItemAnimation::matrixAt ( qreal step ) const

Returns the matrix used to transform the item at the specified step value.

QPointF QGraphicsItemAnimation::posAt ( qreal step ) const

Returns the position of the item at the given step value.

See also setPosAt().

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

Returns all explicitly inserted positions.

See also posAt() and setPosAt().

qreal QGraphicsItemAnimation::rotationAt ( qreal step ) const

Returns the angle at which the item is rotated at the specified step value.

See also setRotationAt().

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

Returns all explicitly inserted rotations.

See also rotationAt() and setRotationAt().

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

Returns all explicitly inserted scales.

See also verticalScaleAt(), horizontalScaleAt(), and setScaleAt().

void QGraphicsItemAnimation::setItem ( QGraphicsItem * item )

Sets the specified item to be used in the animation.

See also item().

void QGraphicsItemAnimation::setPosAt ( qreal step, const QPointF & point )

Sets the position of the item at the given step value to the point specified.

See also posAt().

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

Sets the rotation of the item at the given step value to the angle specified.

See also rotationAt().

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

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

See also verticalScaleAt() and horizontalScaleAt().

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

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

See also verticalShearAt() and horizontalShearAt().

void QGraphicsItemAnimation::setStep ( qreal step )   [slot]

Sets the current step 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 the timeLine specified.

See also timeLine().

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

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

See also xTranslationAt() and yTranslationAt().

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

Returns all explicitly inserted shears.

See also verticalShearAt(), horizontalShearAt(), and setShearAt().

QTimeLine * QGraphicsItemAnimation::timeLine () const

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

See also setTimeLine().

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

Returns all explicitly inserted translations.

See also xTranslationAt(), yTranslationAt(), and setTranslationAt().

qreal QGraphicsItemAnimation::verticalScaleAt ( qreal step ) const

Returns the vertical scale for the item at the specified step value.

See also setScaleAt().

qreal QGraphicsItemAnimation::verticalShearAt ( qreal step ) const

Returns the vertical shear for the item at the specified step value.

See also setShearAt().

qreal QGraphicsItemAnimation::xTranslationAt ( qreal step ) const

Returns the horizontal translation of the item at the specified step value.

See also setTranslationAt().

qreal QGraphicsItemAnimation::yTranslationAt ( qreal step ) const

Returns the vertical translation of the item at the specified step value.

See also setTranslationAt().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 43
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
Page suivante

Le Qt Labs au hasard

Logo

QMake et au-delà, le retour

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.5
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web