[Qt-qml] Error with PropertyAction/SequentialAnimation/Timer

Mark Tucker mark.tucker at airborne.aero
Wed Dec 8 10:10:01 CET 2010


Thanks,

That works!

The behaviour does seem slightly strange though - I would expect the JS function to complete and THEN have everything else updated, but as long as I know that this is the current behaviour I can create code accordingly.

Thanks again

Mark

-----Original Message-----
From: Adriano Rezende [mailto:adriano.rezende at openbossa.org] 
Sent: 07 December 2010 19:16
To: Mark Tucker
Cc: qt-qml at trolltech.com
Subject: Re: [Qt-qml] Error with PropertyAction/SequentialAnimation/Timer

On Tue, Dec 7, 2010 at 12:59 PM, Mark Tucker <mark.tucker at airborne.aero> wrote:
>        Timer {
>                id: textTimer
>                interval: 5000
>                repeat: true
>                running: true
>                triggeredOnStart: true
>                onTriggered: {
>                        listIndex++;
>                        if (listIndex >= model.count) {
>                                listIndex = 0;
>                        }
>                        //console.log("listIndex: " + listIndex + "
> count: " + model.count)
>                        textAnimation.start();
>                }
>        }
> }
> For some reason the PropertyAction is being called when listIndex is 3
> and hence causes an error due to an undefined value. I'm failing to see
> how it should ever be the case that listIndex should be 3 when the
> PropertyAction does its thing though.

I believe QML will reevaluate a JS statement each time you change a
bindable property contained in that statement. So, even if the
animation is not running, "model.get(listIndex).dataString" will be
reevaluated when listIndex changes.
So, in order to solve this problem you can change the code below:

> listIndex++;
> if (listIndex >= model.count) {
>     listIndex = 0;
> }

for the following:

listIndex = (listIndex + 1) % model.count;

Br,
Adriano




More information about the Qt-qml mailing list