[SOLVED] QTimer class probably contains a bug
-
Hi!
I have a problem with QTimer. See code:
@ // this timer is connected to timesUp slot
myTimer->start(18);
}void MainWindow::timesUp()
{
std::cout << QTime::currentTime().msec() << std::endl;
// ...
/* standard output looks like:
278
294
313
331
349
367
384That is right!! */
@BUT:
@ // this timer is connected to timesUp slot
myTimer->start(20);
}/* standard output looks like:
224
256
291
318
351
382
414 */@Why difference is 30ms instead of 20ms?!
Thanks for reply
-
this has been discussed many, many times already... just use the search
Long story short:
- you're (most probably) not using a real-time operating system
- see "QTimer's type property":http://qt-project.org/doc/qt-5.0/qtcore/qtimer.html#timerType-prop
-
Thank you.
I set timer type to Qt::PreciseTimer and now timer is working great. :)