[Qt-qml] QML Timer triggered

Pekka.E.Jokela at nokia.com Pekka.E.Jokela at nokia.com
Thu Oct 20 11:13:58 CEST 2011


Hi,
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:

void QDeclarativeTimer::finished()
{
    Q_D(QDeclarativeTimer);
    if (d->repeating || !d->running)
        return;
    emit triggered();
    d->running = false;
    d->firstTick = false;
    emit runningChanged();
}

Shouldn't the 'running = false' and 'emit triggered()' be the other way around? This is is how the QTimer works i.e. in the timeout() handler the active property 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).

Thanks,
-Pekka

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20111020/e6ee1b3c/attachment-0001.html 


More information about the Qt-qml mailing list