Results 1 to 2 of 2

Thread: QTimer::singleShot stop at 12:00AM on second day

  1. #1
    Join Date
    Aug 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QTimer::singleShot stop at 12:00AM on second day

    I am using QT5 in visual studio.

    I have the function below where I call singleShot for a some ms value according to the GUI (in this case 1000 ms). After single shot has passed it should call reset_TEER() and then rest some values and recall TEER(). This keeps the GUI responsive in-between measurements.

    This works great, except that sometimes at 12:00 AM (midnight) singleshot never times out and the reset_TEER() is never called again. The last time I tried this it ran from 10:39AM 8/20 to 12:00AM 8/22. So, I expect Sunday is the problem, but I can't tell if Sunday is the only day that causes the problem because I have seen this happen once before (at the same midnight time). Other times it works for four days no problem.

    Qt Code:
    1. void CLASS::reset_TEER(){
    2. //do stuff
    3. TEER();
    4. }
    5.  
    6. void CLASS::TEER(){
    7. for(){ //generic for loop here
    8. }
    9. TEER_count++;
    10. if (TEER_count < ui.num_cycles->value() && ui.enable_repeat->isChecked())
    11. QTimer::singleShot(ui.wait_num_cycles->value(), this, SLOT(reset_TEER()));
    12. }
    To copy to clipboard, switch view to plain text mode 

    I can't find any information about why singleShot would do this. I do see that QTime will return to zero after 24 hours but they don't seem related. Should I be doing this a different way?

    Thanks for your input.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer::singleShot stop at 12:00AM on second day

    But this singleShot is conditional. Add something after line 11 :
    Qt Code:
    1. else
    2. qDebug() << "TEER count = " << TEER_count << " num_cyles->value() = " << ui.num_cyles->value() << " enable_repeat->isChecked = " << enable_repeat->isChecked();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTimer::singleShot(0, ... confusion
    By bjoern83 in forum Qt Programming
    Replies: 5
    Last Post: 9th October 2022, 10:30
  2. Replies: 1
    Last Post: 3rd April 2016, 21:39
  3. Replies: 3
    Last Post: 31st January 2010, 16:56
  4. Replies: 8
    Last Post: 10th December 2009, 10:06
  5. multiple QTimer::singleShot() calls?
    By mattc in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2009, 19:22

Tags for this Thread

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.