[Qt-qml] Behavior vs. Follow - 4:1

michael.brasser at nokia.com michael.brasser at nokia.com
Thu Jul 1 07:29:01 CEST 2010


On 29/06/2010, at 8:59 PM, ext Matthias Ettrich wrote:
> In the general case, where you do not have a timer, you can solve this the 
> following way:
> 
> 1. declare the property value where the animation should start
> 2. change it to whatever you like in a Component.onCompleted-handler.
> 
> Example:
> 
> Item {
> 	property int prop: <pre_initial_value>
>    Behaviour on prop{ <funky animation> }
>    Component.onCompleted: prop = <initial_value>
> }
> 
> 
> Alternatively, and probably nicer, you can declare the initial value in a 
> different state "Initial" and simply do 
> 
>   Component.onCompleted: state = "Initial"

This seems like an important alternative, since it is the only way to establish a binding in Component.onCompleted (as opposed to assigning a value).

> To me the onCompleted-approach is appropriate, given that the usecase seems 
> rather esoteric.

A line in the docs or simple example show how to get this Behavior-on-startup behavior would probably be nice if we remove the Follows.

> Main advantage for the follow-removal: no more asymetric API, simpler API, 
> more exposure to the great and flexible Behavior.


Removing the Follows seems reasonable to me.

Michael



More information about the Qt-qml mailing list