

Then I am no longer sure that QTimer is very accurate, although I used Qt::PreciseTimer. But if I look at TIME ELAPSED(QTimer) values, The time resolution for QTimer is very accurate. So if I look only at TIME ELAPSED(QElapsedTimer) values, I might think that TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 11, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 10, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400

TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 9, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 8, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 7, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 10, TIME ELAPSED(QElapsedTimer)= 6, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 5, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400

TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 4, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 3, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 2, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 1, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 The pattern of the debug output in both cases - with or without lambda function - looks like that: TIME ELAPSED(QTimer)= 0, TIME ELAPSED(QElapsedTimer)= 0, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=260374400 I did not try out Qt::QueuedConnection as I was too lazy for this, but if you are very curious, then I will do even that ). Yes, I tried QElapsedTimer with and without a lambda function.
Ctime start a timer 32 bit#
I compile on WIn 7 with mingw-4.9.2 32 bit Dwarf-2.Ĭan you try using a lambda function instead of updatePlot() method? I am curious as to what the result would be there (there should be no difference), and also try connecting to updatePlot() using Qt::QueuedConnection (here it should work worse).
Ctime start a timer windows#
I have to use now an at least 10 years old Windows XP Embedded with 512 MB RAM. Within my updatePlot() SLOT as updatePlot() first does some simple evaluation and only then plots.Īlso, please be aware of this note in the documentation of QTime::elapsed(): "Note that the accuracy depends on the accuracy of the underlying operating system not all systems provide 1-millisecond accuracy." Which I monitor synchronously with my QTimer ( 1ms interval) in order not to miss any new data.Īll these has not been a problem so far, and in the worst case I can downsample the new data
Ctime start a timer pro#
I'll get in the worst case no more than 200 new values pro second,īut these values are delivered into a shared data structure by an asynchronous function, You are aware that updating the plot at 1ms intervals means 1000 Hz refresh rate, while your display is capable of 60Hz as a maximum? Updating so often seems wasteful. I fear I misunderstand something very important said: TIME ELAPSED= 10, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=170244800Ĩ shots of my timer are enqueued into the Qt event handling queue and then "fired"Īll together within one millisecond? Within one nanosecond? The first lines ( as well the next lines ) of the debug output to file have the following pattern: TIME ELAPSED= 0, TIMESPEC Sec=Thu Jan 01 01:00:00 1970, TIMESPEC Nanosec=170244800 I made some debugging within updatePlot() SLOT like that: struct timespec call_data Ĭlock_gettime(CLOCK_PROCESS_CPUTIME_ID, &call_data) įprintf(fp, "TIME ELAPSED= %d, TIMESPEC Sec=%s, TIMESPEC Nanosec=%lu\n", te, ctime(&call_sec),call_nsec ) It means that each time ( in best case once pro ms) timer is shot, my Qwt plot will be updated.

QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updatePlot())) I have this simple piece of code: timer->setTimerType(Qt::PreciseTimer)
