Results 1 to 3 of 3

Thread: QTimer unnestable with every time i stop/start it

  1. #1
    Join Date
    Jan 2012
    Location
    Canary Islands, Spain
    Posts
    86
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QTimer unnestable with every time i stop/start it

    Hi

    I'm trying to make an image slideshow, it's seems simple, when i move to a QListWidget item its start the slideshow, until another item is selected, then stop the timer and start again the same process.
    The problem is every time i select another item, the timer goes "faster". The first selection is fine, timer goes like (1, 2, 3, 4,) (being each number a timer timeout, 1 per second), but the second slection is something like: (1 2, 3 4, 1 2, 3 4) (2 per second), third selection...(1 2 3, 4 1 2, 3 4 1, 2 3 4)...... and more and more....

    the app has a lot of code, so this is how basically im doing it:

    1: On app load, y create the timer.
    2: If the user select an item from the list and slideshow is enbaled, the timer starts, and the slideshow is shown.
    3: If the user select another item, first: if(theTimer->isActive()) { theTimer->stop(); }(i do this because if the user set the SLideshow off, so the timer stops untile Slideshow is enabled again) and then, reload the image list, reset the current image counter, and start the timer again.

    I don't know the why the timeous are stacking or queueing or somethig like that...
    Must i destroy the QTimer and create it every time? If the answer is yes, what is the utilty of QTimmer::stop()??

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTimer unnestable with every time i stop/start it

    The timers may seem to stack if for some reason there are delays in loading some images. If that is the case, you could stop the timer when entering an image and restart it when it has been loaded -- or by other ways seeing that some transitions between images do not get too short.

    (A very first thing to do is to install accurate time measurement with QTime::elapsed())

  3. The following user says thank you to mvuori for this useful post:

    aguayro (20th October 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    Canary Islands, Spain
    Posts
    86
    Thanks
    4
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QTimer unnestable with every time i stop/start it

    ok, was my fault, a dumb connect signal in wrong place.
    Thanks for the help mvuori, thank to you i've dsicarded the timer

Similar Threads

  1. QTimer in QThread doesn't start or timeout
    By Boron in forum Qt Programming
    Replies: 9
    Last Post: 21st October 2011, 13:51
  2. Replies: 2
    Last Post: 28th April 2011, 19:21
  3. Replies: 2
    Last Post: 11th February 2011, 19:48
  4. QTimer don't start
    By Qn00b in forum Qt Programming
    Replies: 13
    Last Post: 7th February 2011, 23:02
  5. Replies: 8
    Last Post: 10th December 2009, 10:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.