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  · 

QML Animation Element

The Animation element is the base of all QML animations. More...

Inherited by AnchorAnimation, ParallelAnimation, ParentAnimation, PauseAnimation, PropertyAction, PropertyAnimation, ScriptAction, and SequentialAnimation.

This element was introduced in Qt 4.7.

Properties

Methods

Detailed Description

The Animation element cannot be used directly in a QML file. It exists to provide a set of common properties and methods, available across all the other animation types that inherit from it. Attempting to use the Animation element directly will result in an error.

Property Documentation

alwaysRunToEnd : bool

This property holds whether the animation should run to completion when it is stopped.

If this true the animation will complete its current iteration when it is stopped - either by setting the running property to false, or by calling the stop() method. The complete() method is not effected by this value.

This behavior is most useful when the repeat property is set, as the animation will finish playing normally but not restart.

By default, the alwaysRunToEnd property is not set.

Note: alwaysRunToEnd has no effect on animations in a Transition.


loops : int

This property holds the number of times the animation should play.

By default, loops is 1: the animation will play through once and then stop.

If set to Animation.Infinite, the animation will continuously repeat until it is explicitly stopped - either by setting the running property to false, or by calling the stop() method.

In the following example, the rectangle will spin indefinitely.

 Rectangle {
     width: 100; height: 100; color: "green"
     RotationAnimation on rotation {
         loops: Animation.Infinite
         from: 0
         to: 360
     }
 }

paused : bool

This property holds whether the animation is currently paused.

The paused property can be set to declaratively control whether or not an animation is paused.

Animations can also be paused and resumed imperatively from JavaScript using the pause() and resume() methods.

By default, animations are not paused.


running : bool

This property holds whether the animation is currently running.

The running property can be set to declaratively control whether or not an animation is running. The following example will animate a rectangle whenever the MouseArea is pressed.

 Rectangle {
     width: 100; height: 100
     NumberAnimation on x {
         running: myMouse.pressed
         from: 0; to: 100
     }
     MouseArea { id: myMouse }
 }

Likewise, the running property can be read to determine if the animation is running. In the following example the text element will indicate whether or not the animation is running.

 NumberAnimation { id: myAnimation }
 Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }

Animations can also be started and stopped imperatively from JavaScript using the start() and stop() methods.

By default, animations are not running. Though, when the animations are assigned to properties, as property value sources using the on syntax, they are set to running by default.


Method Documentation

Animation::complete ()

Stops the animation, jumping to the final property values.

If the animation is not running, calling this method has no effect. The running property will be false following a call to complete().

Unlike stop(), complete() immediately fast-forwards the animation to its end. In the following example,

 Rectangle {
     NumberAnimation on x { from: 0; to: 100; duration: 500 }
 }

calling stop() at time 250ms will result in the x property having a value of 50, while calling complete() will set the x property to 100, exactly as though the animation had played the whole way through.


Animation::pause ()

Pauses the animation.

If the animation is already paused, calling this method has no effect. The paused property will be true following a call to pause().


Animation::restart ()

Restarts the animation.

This is a convenience method, and is equivalent to calling stop() and then start().


Animation::resume ()

Resumes a paused animation.

If the animation is not paused, calling this method has no effect. The paused property will be false following a call to resume().


Animation::start ()

Starts the animation.

If the animation is already running, calling this method has no effect. The running property will be true following a call to start().


Animation::stop ()

Stops the animation.

If the animation is not running, calling this method has no effect. The running property will be false following a call to stop().

Normally stop() stops the animation immediately, and the animation has no further influence on property values. In this example animation

 Rectangle {
     NumberAnimation on x { from: 0; to: 100; duration: 500 }
 }

was stopped at time 250ms, the x property will have a value of 50.

However, if the alwaysRunToEnd property is set, the animation will continue running until it completes and then stop. The running property will still become false immediately.


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 64
  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. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Extension de Qt WebKit

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.7-snapshot
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