Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. Cannot update label or lcd in real time.
Forum Updated to NodeBB v4.3 + New Features

Cannot update label or lcd in real time.

Scheduled Pinned Locked Moved Qt in Education
5 Posts 3 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtniv
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      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->setTimerType(Qt::PreciseTimer);
      connect(t, &QTimer::timeout,
      myWidget, &MyWidget::updateDisplay);

      t->start(10); // emit a timeout() signal every 10 ms
      @

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mehrdadsilver
        wrote on last edited by
        #3

        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.

        Mehrdad Abdolghafari, Be silver

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          [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

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mehrdadsilver
            wrote on last edited by
            #5

            dear JKSH,
            yes, your idea is true.
            thanks.

            Mehrdad Abdolghafari, Be silver

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved