[Qt-qml] QML Timer triggered

Bo Thorsen bo at fioniasoftware.dk
Fri Oct 21 08:13:52 CEST 2011


You need a restart flag. Otherwise, one way to look at it will fail.

Bo.

Den 21-10-2011 07:36, Pekka.E.Jokela at nokia.com skrev:
> Thanks!
>
> ØA slightly more tricky question is, what should the running property
> report from within the onTriggered handler in such a case?
>
> I guess there is no “ultimate solution”. To me the QTimer solution
> sounds intuitive aka running is false when the timer has done its job
> and reported that the time has been (well) spent.
>
> -P
>
> *From:*Kennedy Aaron (Nokia-MP-Qt/Brisbane)
> *Sent:* 21 October, 2011 03:10
> *To:* Brasser Michael (Nokia-MP-Qt/Brisbane); Jokela Pekka.E
> (Nokia-MP-Qt/Tampere)
> *Cc:* qt-qml at qt.nokia.com
> *Subject:* RE: [Qt-qml] QML Timer triggered
>
> Hi,
>
> That you cannot restart the timer from within the onTriggered handler is
> definitely wrong.
>
> A slightly more tricky question is, what should the running property
> report from within the onTriggered handler in such a case?
>
> Cheers,
>
>
> Aaron
>
> ------------------------------------------------------------------------
>
> *From:*qt-qml-bounces+aaron.kennedy=nokia.com at qt.nokia.com
> <mailto:qt-qml-bounces+aaron.kennedy=nokia.com at qt.nokia.com>
> [qt-qml-bounces+aaron.kennedy=nokia.com at qt.nokia.com] on behalf of
> Brasser Michael (Nokia-MP-Qt/Brisbane)
> *Sent:* Friday, October 21, 2011 9:46 AM
> *To:* Jokela Pekka.E (Nokia-MP-Qt/Tampere)
> *Cc:* qt-qml at qt.nokia.com <mailto:qt-qml at qt.nokia.com>
> *Subject:* Re: [Qt-qml] QML Timer triggered
>
> Hi,
>
> On 20/10/2011, at 7:13 PM, ext Pekka.E.Jokela at nokia.com
> <mailto:Pekka.E.Jokela at nokia.com> wrote:
>
>     Is the timer buggy or “works as specified”:
>
>     Timer {
>
>     repeat: false
>
>     onTriggered: {
>
>     console.log(running) // true – I would assume false in non-repeating
>     timer
>
>     restart() // does not work – it calls stop and start but the timer
>     stops this automatically
>
>     }
>
>     }
>
>     The issue is clear when looking at the implementation:
>
>     voidQDeclarativeTimer::finished()
>
>     {
>
>     Q_D(QDeclarativeTimer);
>
>     if(d->repeating||!d->running)
>
>     return;
>
>     emit triggered();
>
>     d->running = false;
>
>     d->firstTick=false;
>
>     emitrunningChanged();
>
>     }
>
>     Shouldn’t the ‘running = false’ and ‘emit triggered()’ be the other
>     way around? This is is how the QTimer works i.e. in
>     thetimeout()handler theactiveproperty is already set to false and it
>     can be restarted.
>
>     If this really is the wanted behavior, how do I restart the timer in
>     the onTriggered event handler without setting the repeat to true (I
>     use the same timer for many things and the repeat would just mess up
>     everything).
>
> I don't think the current behavior is intentional. You can follow the
> issue at https://bugreports.qt.nokia.com/browse/QTBUG-22004.
>
> Regards,
>
> Michael
>
>
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml


Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk


More information about the Qt-qml mailing list