Qt World Summit: Submit your Presentation

[SOLVED]QTimeLine setPaused doesn't pause the time line correctly

  • I am using QTimeLine with Qt 4.8.4 and it seems that the implementation for setPaused() doesn't actually pause the timeline correctly. In basic terms I have setup a QTimeLine with a duration of 5000 msecs. During the run of this timeline I can pause the timeline with a button and click the same button again to resume. On resume the time line immediately finishes!

    On checking the Qt source for QTimeLine it seems that on resume the QTimeLinePrivate::setCurrentTime() function is called on line 5 of this function (qtimeline.cpp line 100) it uses a value called elapsed to determine the number of loops that the timeline has performed this elapsed value contains a far larger value than expected (almost as if it hasn't stopped logging the elapsed time on pause) this value resolves to a large loop count which automatically stops the time line on that call. This seems wrong (I would expect the time line's elapsed value to only increment when the timeline is running) The upshot of this is that I cannot rely on pausing the timeline as it doesn't correctly pause.

    Is there a workaround or a fix for this so I can continue to use QTimeLine in my application or even a suggestion of what I might be doing wrong to cause this issue

  • Hi,
    Think you confused the resume() and setPaused(false) functions! The resume is stated in the docs that it will resume from the currentTime.
    The setPaused(false) continues as is when you setPaused(true)

  • Thanks for the quick and very correct response Jeroen, that was exactly my problem.

  • Oke, edit your topic with [SOLVED] in front of it. that will make sure no other people will keep reading it unless they need the same answer ;-)

  • And welcome to the Qt-Project forum. Have fun with coding!

Log in to reply