Cannot update label or lcd in real time.
I making a stopwatch. and I need to keep updating the display with change in milliseconds , seconds, minutes and hours.
I tried using lcdnumber first but it was updating slowly. and label doesn't even update. please suggest, how to update after each millisecond or 1/100th of a second.
First ,some notes:
- PCs are not real-time systems. If your thread is experiencing a heavy load, your timer can be off by several milliseconds. These timing errors are called "jitter":http://en.wikipedia.org/wiki/Jitter
- Each time you update your display, you should measure the true elapsed time using a QElapsedTimer. If you simply count the number of times you've updated, jitter will cause your stopwatch error to keep growing over time.
- You can't actually see your display update every millisecond because (i) most LCD screens only update every 16.7 ms (60 Hz refresh rate) and (ii) the human eye can't perceive changes at 1 kHz anyway
[quote]label doesn’t even update.[/quote]
Can you show us the code that you're using to update your displays?
It is possible to update the value of a QLCDNumber or QLabel every ~1 ms. However, remember that your stopwatch will carry an uncertainty of several milliseconds.
On Windows, you'll need to specify a high-precision timer to get millisecond resolution.
QTimer* t = new QTimer();
t->start(10); // emit a timeout() signal every 10 ms
if you are developing on Microsoft Windows, the minimum real interval is 17 - 25 ms. if you set interval to 10, you will get interval minimum 16-25 ms. I suggest you using Linux.
[quote author="mehrdadsilver" date="1380011257"]if you are developing on Microsoft Windows, the minimum real interval is 17 - 25 ms. if you set interval to 10, you will get interval minimum 16-25 ms. I suggest you using Linux.[/quote]Not true. I got 1 ms quite reliably on Windows 8 x64 using Qt::PreciseTimer
yes, your idea is true.