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

  • Qt 4.8
  • PropertyAnimation QML Element

PropertyAnimation QML Element

ThePropertyAnimation element animates changes in property values.More...

Properties

Detailed Description

PropertyAnimation provides a way to animate changes to a property's value.

It can be used to define animations in a number of ways:

  • In aTransition

    For example, to animate any objects that have changed theirx ory properties as a result of a state change, using anInOutQuad easing curve:

    Rectangle {id:rectwidth:100;height:100color:"red"states:State {name:"moved"PropertyChanges {target:rect;x:50 }    }transitions:Transition {PropertyAnimation {properties:"x,y";easing.type:Easing.InOutQuad }    }}
  • In aBehavior

    For example, to animate all changes to a rectangle'sx property:

    Rectangle {width:100;height:100color:"red"    Behavior onx {PropertyAnimation {} }MouseArea {anchors.fill:parent;onClicked:parent.x=50 }}
  • As a property value source

    For example, to repeatedly animate the rectangle'sx property:

    Rectangle {width:100;height:100color:"red"    SequentialAnimation onx {loops:Animation.InfinitePropertyAnimation {to:50 }PropertyAnimation {to:0 }    }}
  • In a signal handler

    For example, to fade outtheObject when clicked:

    MouseArea {anchors.fill:theObjectonClicked:PropertyAnimation {target:theObject;property:"opacity";to:0 }}
  • Standalone

    For example, to animaterect'swidth property over 500ms, from its current width to 30:

    Rectangle {id:theRectwidth:100;height:100color:"red"// this is a standalone animation, it's not running by defaultPropertyAnimation {id:animation;target:theRect;property:"width";to:30;duration:500 }MouseArea {anchors.fill:parent;onClicked:animation.running=true }}

Depending on how the animation is used, the set of properties normally used will be different. For more information see the individual property documentation, as well as theQML Animation and Transitions introduction.

Note thatPropertyAnimation inherits the abstractAnimation element. This includes additional properties and methods for controlling the animation.

See alsoQML Animation and Transitions and Animation basics example.

Property Documentation

duration :int

This property holds the duration of the animation, in milliseconds.

The default value is 250.


easing group

easing.type :enumeration

easing.amplitude :real

easing.overshoot :real

easing.period :real

the easing curve used for the animation.

To specify an easing curve you need to specify at least the type. For some curves you can also specify amplitude, period and/or overshoot (more details provided after the table). The default easing curve isEasing.Linear.

PropertyAnimation {properties:"y";easing.type:Easing.InOutElastic;easing.amplitude:2.0;easing.period:1.5 }

Available types are:

Easing.LinearEasing curve for a linear (t) function: velocity is constant.
Easing.InQuadEasing curve for a quadratic (t^2) function: accelerating from zero velocity.
Easing.OutQuadEasing curve for a quadratic (t^2) function: decelerating to zero velocity.
Easing.InOutQuadEasing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
Easing.OutInQuadEasing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
Easing.InCubicEasing curve for a cubic (t^3) function: accelerating from zero velocity.
Easing.OutCubicEasing curve for a cubic (t^3) function: decelerating from zero velocity.
Easing.InOutCubicEasing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
Easing.OutInCubicEasing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
Easing.InQuartEasing curve for a quartic (t^4) function: accelerating from zero velocity.
Easing.OutQuartEasing curve for a quartic (t^4) function: decelerating from zero velocity.
Easing.InOutQuartEasing curve for a quartic (t^4) function: acceleration until halfway, then deceleration.
Easing.OutInQuartEasing curve for a quartic (t^4) function: deceleration until halfway, then acceleration.
Easing.InQuintEasing curve for a quintic (t^5) function: accelerating from zero velocity.
Easing.OutQuintEasing curve for a quintic (t^5) function: decelerating from zero velocity.
Easing.InOutQuintEasing curve for a quintic (t^5) function: acceleration until halfway, then deceleration.
Easing.OutInQuintEasing curve for a quintic (t^5) function: deceleration until halfway, then acceleration.
Easing.InSineEasing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
Easing.OutSineEasing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
Easing.InOutSineEasing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
Easing.OutInSineEasing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
Easing.InExpoEasing curve for an exponential (2^t) function: accelerating from zero velocity.
Easing.OutExpoEasing curve for an exponential (2^t) function: decelerating from zero velocity.
Easing.InOutExpoEasing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
Easing.OutInExpoEasing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
Easing.InCircEasing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
Easing.OutCircEasing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
Easing.InOutCircEasing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
Easing.OutInCircEasing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
Easing.InElasticEasing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
The peak amplitude can be set with theamplitude parameter, and the period of decay by theperiod parameter.
Easing.OutElasticEasing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
The peak amplitude can be set with theamplitude parameter, and the period of decay by theperiod parameter.
Easing.InOutElasticEasing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
Easing.OutInElasticEasing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
Easing.InBackEasing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
Easing.OutBackEasing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
Easing.InOutBackEasing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
Easing.OutInBackEasing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
Easing.InBounceEasing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
Easing.OutBounceEasing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
Easing.InOutBounceEasing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
Easing.OutInBounceEasing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.

easing.amplitude is only applicable for bounce and elastic curves (curves of typeEasing.InBounce,Easing.OutBounce,Easing.InOutBounce,Easing.OutInBounce,Easing.InElastic,Easing.OutElastic,Easing.InOutElastic orEasing.OutInElastic).

easing.overshoot is only applicable ifeasing.type is:Easing.InBack,Easing.OutBack,Easing.InOutBack orEasing.OutInBack.

easing.period is only applicable if easing.type is:Easing.InElastic,Easing.OutElastic,Easing.InOutElastic orEasing.OutInElastic.

See theeasing example for a demonstration of the different easing settings.


exclude :list<Object>

This property holds the items not to be affected by this animation.

See alsoPropertyAnimation::targets.


from :real

This property holds the starting value for the animation.

If thePropertyAnimation is defined within aTransition orBehavior, this value defaults to the value defined in the starting state of theTransition, or the current value of the property at the moment theBehavior is triggered.

See alsoQML Animation and Transitions.


properties :string

These properties are used as a set to determine which properties should be animated. The singular and plural forms are functionally identical, e.g.

NumberAnimation {target:theItem;property:"x";to:500 }

has the same meaning as

NumberAnimation {targets:theItem;properties:"x";to:500 }

The singular forms are slightly optimized, so if you do have only a single target/property to animate you should try to use them.

Thetargets property allows multiple targets to be set. For example, this animates thex property of bothitemA anditemB:

NumberAnimation {targets: [itemA,itemB];properties:"x";to:500 }

In many cases these properties do not need to be explicitly specified, as they can be inferred from the animation framework:

Value Source / BehaviorWhen an animation is used as a value source or in a Behavior, the default target and property name to be animated can both be inferred.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)       NumberAnimation onx {to:500;loops:Animation.Infinite }//animate theRect's x property       Behavior ony {NumberAnimation {} }//animate theRect's y property   }
TransitionWhen used in a transition, a property animation is assumed to matchall targets butno properties. In practice, that means you need to specify at least the properties in order for the animation to do anything.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)Item {id:uselessItem }states:State {name:"state1"PropertyChanges {target:theRect;x:200;y:200;z:4 }PropertyChanges {target:uselessItem;x:10;y:10;z:2 }       }transitions:Transition {//animate both theRect's and uselessItem's x and y to their final valuesNumberAnimation {properties:"x,y" }//animate theRect's z to its final valueNumberAnimation {target:theRect;property:"z" }       }   }
StandaloneWhen an animation is used standalone, both the target and property need to be explicitly specified.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)//need to explicitly specify target and propertyNumberAnimation {id:theAnim;target:theRect;property:"x";to:500 }MouseArea {anchors.fill:parentonClicked:theAnim.start()       }   }

As seen in the above example, properties is specified as a comma-separated string of property names to animate.

See alsoexclude andQML Animation and Transitions.


property :string

These properties are used as a set to determine which properties should be animated. The singular and plural forms are functionally identical, e.g.

NumberAnimation {target:theItem;property:"x";to:500 }

has the same meaning as

NumberAnimation {targets:theItem;properties:"x";to:500 }

The singular forms are slightly optimized, so if you do have only a single target/property to animate you should try to use them.

Thetargets property allows multiple targets to be set. For example, this animates thex property of bothitemA anditemB:

NumberAnimation {targets: [itemA,itemB];properties:"x";to:500 }

In many cases these properties do not need to be explicitly specified, as they can be inferred from the animation framework:

Value Source / BehaviorWhen an animation is used as a value source or in a Behavior, the default target and property name to be animated can both be inferred.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)       NumberAnimation onx {to:500;loops:Animation.Infinite }//animate theRect's x property       Behavior ony {NumberAnimation {} }//animate theRect's y property   }
TransitionWhen used in a transition, a property animation is assumed to matchall targets butno properties. In practice, that means you need to specify at least the properties in order for the animation to do anything.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)Item {id:uselessItem }states:State {name:"state1"PropertyChanges {target:theRect;x:200;y:200;z:4 }PropertyChanges {target:uselessItem;x:10;y:10;z:2 }       }transitions:Transition {//animate both theRect's and uselessItem's x and y to their final valuesNumberAnimation {properties:"x,y" }//animate theRect's z to its final valueNumberAnimation {target:theRect;property:"z" }       }   }
StandaloneWhen an animation is used standalone, both the target and property need to be explicitly specified.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)//need to explicitly specify target and propertyNumberAnimation {id:theAnim;target:theRect;property:"x";to:500 }MouseArea {anchors.fill:parentonClicked:theAnim.start()       }   }

As seen in the above example, properties is specified as a comma-separated string of property names to animate.

See alsoexclude andQML Animation and Transitions.


target :Object

These properties are used as a set to determine which properties should be animated. The singular and plural forms are functionally identical, e.g.

NumberAnimation {target:theItem;property:"x";to:500 }

has the same meaning as

NumberAnimation {targets:theItem;properties:"x";to:500 }

The singular forms are slightly optimized, so if you do have only a single target/property to animate you should try to use them.

Thetargets property allows multiple targets to be set. For example, this animates thex property of bothitemA anditemB:

NumberAnimation {targets: [itemA,itemB];properties:"x";to:500 }

In many cases these properties do not need to be explicitly specified, as they can be inferred from the animation framework:

Value Source / BehaviorWhen an animation is used as a value source or in a Behavior, the default target and property name to be animated can both be inferred.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)       NumberAnimation onx {to:500;loops:Animation.Infinite }//animate theRect's x property       Behavior ony {NumberAnimation {} }//animate theRect's y property   }
TransitionWhen used in a transition, a property animation is assumed to matchall targets butno properties. In practice, that means you need to specify at least the properties in order for the animation to do anything.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)Item {id:uselessItem }states:State {name:"state1"PropertyChanges {target:theRect;x:200;y:200;z:4 }PropertyChanges {target:uselessItem;x:10;y:10;z:2 }       }transitions:Transition {//animate both theRect's and uselessItem's x and y to their final valuesNumberAnimation {properties:"x,y" }//animate theRect's z to its final valueNumberAnimation {target:theRect;property:"z" }       }   }
StandaloneWhen an animation is used standalone, both the target and property need to be explicitly specified.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)//need to explicitly specify target and propertyNumberAnimation {id:theAnim;target:theRect;property:"x";to:500 }MouseArea {anchors.fill:parentonClicked:theAnim.start()       }   }

As seen in the above example, properties is specified as a comma-separated string of property names to animate.

See alsoexclude andQML Animation and Transitions.


targets :list<Object>

These properties are used as a set to determine which properties should be animated. The singular and plural forms are functionally identical, e.g.

NumberAnimation {target:theItem;property:"x";to:500 }

has the same meaning as

NumberAnimation {targets:theItem;properties:"x";to:500 }

The singular forms are slightly optimized, so if you do have only a single target/property to animate you should try to use them.

Thetargets property allows multiple targets to be set. For example, this animates thex property of bothitemA anditemB:

NumberAnimation {targets: [itemA,itemB];properties:"x";to:500 }

In many cases these properties do not need to be explicitly specified, as they can be inferred from the animation framework:

Value Source / BehaviorWhen an animation is used as a value source or in a Behavior, the default target and property name to be animated can both be inferred.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)       NumberAnimation onx {to:500;loops:Animation.Infinite }//animate theRect's x property       Behavior ony {NumberAnimation {} }//animate theRect's y property   }
TransitionWhen used in a transition, a property animation is assumed to matchall targets butno properties. In practice, that means you need to specify at least the properties in order for the animation to do anything.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)Item {id:uselessItem }states:State {name:"state1"PropertyChanges {target:theRect;x:200;y:200;z:4 }PropertyChanges {target:uselessItem;x:10;y:10;z:2 }       }transitions:Transition {//animate both theRect's and uselessItem's x and y to their final valuesNumberAnimation {properties:"x,y" }//animate theRect's z to its final valueNumberAnimation {target:theRect;property:"z" }       }   }
StandaloneWhen an animation is used standalone, both the target and property need to be explicitly specified.
Rectangle {id:theRectwidth:100;height:100color:Qt.rgba(0,0,1)//need to explicitly specify target and propertyNumberAnimation {id:theAnim;target:theRect;property:"x";to:500 }MouseArea {anchors.fill:parentonClicked:theAnim.start()       }   }

As seen in the above example, properties is specified as a comma-separated string of property names to animate.

See alsoexclude andQML Animation and Transitions.


to :real

This property holds the end value for the animation.

If thePropertyAnimation is defined within aTransition orBehavior, this value defaults to the value defined in the end state of theTransition, or the value of the property change that triggered theBehavior.

See alsoQML Animation and Transitions.


© 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