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. timerEvent response overtime
Forum Updated to NodeBB v4.3 + New Features

timerEvent response overtime

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 327 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.
  • W Offline
    W Offline
    wang1209
    wrote on last edited by wang1209
    #1

    I override a timerEvent and set its interval to 10 ms. Then I build the same code both in Windows 10 and Ubuntu 22.04. During run time, the Win version sometimes responsed between two timer slices over 50 ms, even 1 or 2 seconds. But the Ubuntu version run normly. Does it need more configuration in Windows' enviroment?

    Christian EhrlicherC JonBJ 2 Replies Last reply
    0
    • W wang1209

      I override a timerEvent and set its interval to 10 ms. Then I build the same code both in Windows 10 and Ubuntu 22.04. During run time, the Win version sometimes responsed between two timer slices over 50 ms, even 1 or 2 seconds. But the Ubuntu version run normly. Does it need more configuration in Windows' enviroment?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @wang1209 said in timerEvent response overtime:

      Does it need more configuration in Windows' enviroment?

      No, nothing you can do except you switch to a real-time OS.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • W wang1209

        I override a timerEvent and set its interval to 10 ms. Then I build the same code both in Windows 10 and Ubuntu 22.04. During run time, the Win version sometimes responsed between two timer slices over 50 ms, even 1 or 2 seconds. But the Ubuntu version run normly. Does it need more configuration in Windows' enviroment?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @wang1209
        I don't use Windows but did you read through enum Qt::TimerType and try Qt::PreciseTimer? Or there is QChronoTimer, though I think that is overkill for 10ms.

        W 1 Reply Last reply
        1
        • JonBJ JonB

          @wang1209
          I don't use Windows but did you read through enum Qt::TimerType and try Qt::PreciseTimer? Or there is QChronoTimer, though I think that is overkill for 10ms.

          W Offline
          W Offline
          wang1209
          wrote on last edited by
          #4

          @JonB Yes, I set the second parameter as Qt::PreciseTimer when I call startTimer() like

          timerID=startTimer(10, Qt::PreciseTimer);
          
          JonBJ Pl45m4P 2 Replies Last reply
          0
          • W wang1209

            @JonB Yes, I set the second parameter as Qt::PreciseTimer when I call startTimer() like

            timerID=startTimer(10, Qt::PreciseTimer);
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @wang1209
            Well all I know is that the link says

            On Windows, Qt will use Windows's Multimedia timer facility (if available) for Qt::PreciseTimer and normal Windows timers for Qt::CoarseTimer and Qt::VeryCoarseTimer.

            Maybe Multimedia timer is not available to you or it's still not accurate, I don't know. For the sake of completeness did you check QChronoTimer? You could also test Windows native WM_TIMER or other to see if it's any more accurate than from Qt. If you can't find anything more accurate in Windows then as @Christian-Ehrlicher says maybe you'll never get it out of non-real-time Windows.

            1 Reply Last reply
            0
            • W wang1209

              @JonB Yes, I set the second parameter as Qt::PreciseTimer when I call startTimer() like

              timerID=startTimer(10, Qt::PreciseTimer);
              
              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @wang1209

              • https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/high-resolution-timers#controlling-timer-accuracy

              You can't rely on Windows timer precision in exact milliseconds.
              Don't know how Qt's "precise" timer is implemented and what it does to the OS (i.e. Windows)...
              as @JonB and @Christian-Ehrlicher say above, for very time sensitive tasks, an RTOS such as QNX or ROS is more suited... but all depends on your use case.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              0
              • JonBJ JonB referenced this topic on
              • JonBJ JonB referenced this topic on

              • Login

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