[Qt-interest] setPaused Does Not Resume QTimeLine Where Paused

Marc 'Tafouk' mt-gmane at millie.uk.to
Sat Jul 30 17:28:50 CEST 2011


Karol Krizka <kkrizka <at> gmail.com> writes:

> 
> Hi there,
> 
> I've run into a problem. I'm using QTimeLine to control an animation,
> and I'm adding controls like play/pause buttons. Obviously, for this I'm
> using the QTimeLine::setPaused(bool) to pause it.
> 
> According to the documentation:
> "If paused is false, the timeline is resumed and continues where it
> left."
> 
> However that is not what I'm experiencing on Ubuntu Jaunty with Qt
> 4.5.1. I've created a simple application where I start a timeline and
> connect the QTimeLine::valueChanged(qreal) to a simple slot where I just
> print out the value of the time. Then I connect a checkbox button's
> toggled(bool) signal to QTimeLine::setPaused(bool).
> 
> Here is what I see. When I hit pause, the timeline stops sending the
> valueChanged(qreal) signal as documented. However, when I resume the
> time line it starts at a later time and not where I paused. Here is the
> output around the point where I pause:
> 
> 0.104922 
> 0.108805 
> 0.112748 
> 0.116753
> PAUSED HERE 
> 0.630572 
> 0.636627 
> 0.64266 
> 
> Is this a bug or something I'm not understanding from the documentation?
> 
> I've attached the test project.
> --
> Cheers,
> Karol Krizka
> 
> Attachment (test1.zip): application/zip, 1991 bytes
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest <at> trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 


Hello folks,

I hit the same (2-year old) problem as Karol when trying to use a QTimeLine.
Upon looking at qtimeline.cpp, it seems QTimeLine::setPaused(false) and 
QTimeLine::resume() are separate code paths when reactivating a paused timeline.

The documentation does not seem to hint at this, would you say it is intended?

resume():
    //...
    d->timerId = startTimer(d->updateInterval);
    d->startTime = d->currentTime;
    d->timer.start();
    d->setState(Running);

setPaused(paused):
    //...
    } else if (!paused && d->state == Paused) {
        d->timerId = startTimer(d->updateInterval);
        d->setState(Running);
    }

Regards,
Marc





More information about the Qt-interest-old mailing list