Results 1 to 2 of 2

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

  1. #1
    Join Date
    Aug 2016
    Qt products

    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. }
    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
    Kraków, Poland
    Thanked 279 Times in 274 Posts
    Qt products
    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. Replies: 1
    Last Post: 3rd April 2016, 22:39
  2. QTimer::singleShot(0, ... confusion
    By bjoern83 in forum Qt Programming
    Replies: 4
    Last Post: 19th April 2010, 14:45
  3. Replies: 3
    Last Post: 31st January 2010, 17:56
  4. Replies: 8
    Last Post: 10th December 2009, 11:06
  5. multiple QTimer::singleShot() calls?
    By mattc in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2009, 20:22

Tags for this Thread


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.