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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

RotationAnimation

The RotationAnimation element animates changes in rotation values. More...

Inherits PropertyAnimation

Properties

Detailed Description

RotationAnimation is a specialized PropertyAnimation that gives control over the direction of rotation during an animation.

By default, it rotates in the direction of the numerical change; a rotation from 0 to 240 will rotate 240 degrees clockwise, while a rotation from 240 to 0 will rotate 240 degrees counterclockwise. The direction property can be set to specify the direction in which the rotation should occur.

In the following example we use RotationAnimation to animate the rotation between states via the shortest path:

 import QtQuick 2.0

 Item {
     width: 300; height: 300

     Rectangle {
         id: rect
         width: 150; height: 100; anchors.centerIn: parent
         color: "red"
         smooth: true

         states: State {
             name: "rotated"
             PropertyChanges { target: rect; rotation: 180 }
         }

         transitions: Transition {
             RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
         }
     }

     MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" }
 }

Notice the RotationAnimation did not need to set a target value. As a convenience, when used in a transition, RotationAnimation will rotate all properties named "rotation" or "angle". You can override this by providing your own properties via properties or property.

Also, note the Rectangle will be rotated around its default transformOrigin (which is Item.Center). To use a different transform origin, set the origin in the PropertyChanges object and apply the change at the start of the animation using PropertyAction. See the PropertyAction documentation for more details.

Like any other animation element, a RotationAnimation can be applied in a number of ways, including transitions, behaviors and property value sources. The QML Animation and Transitions documentation shows a variety of methods for creating animations.

See also QML Animation and Transitions and Animation basics example.

Property Documentation

direction : enumeration

This property holds the direction of the rotation.

Possible values are:

  • RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers. A rotation from 10 to 350 will rotate 340 degrees clockwise.
  • RotationAnimation.Clockwise - Rotate clockwise between the two values
  • RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values
  • RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path. A rotation from 10 to 350 will rotate 20 degrees counterclockwise.

from : real

This property holds the starting value for the animation.

For example, the following animation is not applied until the angle value has reached 100:

 Item {
     states: [
         // ...
     ]

     transition: Transition {
         RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
     }
 }

If the RotationAnimation is defined within a Transition or Behavior, this value defaults to the value defined in the starting state of the Transition, or the current value of the property at the moment the Behavior is triggered.

See also QML Animation and Transitions.


to : real

This property holds the end value for the animation..

If the RotationAnimation is defined within a Transition or Behavior, this value defaults to the value defined in the end state of the Transition, or the value of the property change that triggered the Behavior.

See also QML Animation and Transitions.


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 5.0-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