[Qt-qml] StateChangeScript - why do we have it?

Girish Ramakrishnan girish at forwardbias.in
Mon Dec 27 05:20:54 CET 2010


Hi,

On Mon, Dec 27, 2010 at 12:48 AM, Ville M. Vainio <vivainio at gmail.com> wrote:
> StateChangeScript executes a script when you enter a State:
>
> State {
>     name "state1"
>     StateChangeScript {
>         name: "myScript"
>         script: doStateStuff();
>     }
>     ...
>  }
>
> To a naive observer, it would seem more elegant to have the State emit
> a signal when you enter it:
>
> State {
>     name "state1"
>
>     onEntered: {
>         doStateStuff();
>     }
>     ...
>  }
>
> I guess there is a good rationale for this that evades plain sight?
>

When you have multiple changes in a state, you can control when the
script gets executed in a transition using ScriptAction. For example,
if you have 3 PropertyChange and a StateChangeScript, you can have the
script execute after 2 PropertyChanges. With something like onEntered,
the script would always have to run at the beginning of the
transition.

Girish


More information about the Qt-qml mailing list