Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QTimer class probably contains a bug
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QTimer class probably contains a bug

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k 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.
  • B Offline
    B Offline
    Bambo
    wrote on last edited by
    #1

    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
    384

    That 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

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bambo
        wrote on last edited by
        #3

        Thank you.
        I set timer type to Qt::PreciseTimer and now timer is working great. :)

        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