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. QTimer too much that make some slots of timeout() do not work?

QTimer too much that make some slots of timeout() do not work?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.4k 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.
  • C Offline
    C Offline
    cq441745656
    wrote on last edited by
    #1

    I am in a project,what control many serials and Ui(s--),so any QTimer(about 30 timers) is necessary in the project.
    but now i have a problem , I didn't recieve the signal named timeout() for a long time even in the main thread.
    All interval of these timers are less than 5s.
    I have heard of that the number of timers is a limit, but i don't know what the excatly the number is .
    Or there may some other way solve this problem.
    please help me with that.
    even a small suggest is a big help,thx.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cq441745656
      wrote on last edited by
      #2

      by the way,just a little part of timer(about 10) is away running , the least are depend control of user.
      OS:ubuntu 10.04
      QT VN: qt-4.7.4 for desktop

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adrien Leravat
        wrote on last edited by
        #3

        Hi,

        I don't think the issue here is the number of timers. Usually that's because of one or more called slot (directly or indirectly) blocking the execution of your program. If a slot makes your thread busy working for 1s, and you have a timer that was scheduled to timeout at 0.5s, it will be delayed to 1s+. And this second call may delay even more a third timer etc.

        You can monitor the time you spend in your slot to know if you are facing this issue.

        Also remember that signal/slots connections are synchronous by default, if you have a single thread.

        Adeneo Embedded - www.adeneo-embedded.com

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cq441745656
          wrote on last edited by
          #4

          thank for your quote, kind Adrien Leravat.
          But my timer have been delay for a whole night.
          It use for updating the current time on a label. i start my program at night and it update time normally at that time.But in next morning ,it was stop and the time was just yesterday.it really mean timer have been delayed for that long?
          i also found that sometime,after an hour or more,it execute just once .

          by the way,if reducing my timers,it work well.just as you say,i agree you ap
          inion about nothing to be unconcerned with the count of timer. just don't know why.
          The code in my program just the same as below:
          connect (myTimer,SIGNAL(timeout()),this,SLOT(slotUpdateTime));
          myTimer->start(1000);

          [quote author="Adrien Leravat" date="1373356031"]Hi,

          I don't think the issue here is the number of timers. Usually that's because of one or more called slot (directly or indirectly) blocking the execution of your program. If a slot makes your thread busy working for 1s, and you have a timer that was scheduled to timeout at 0.5s, it will be delayed to 1s+. And this second call may delay even more a third timer etc.

          You can monitor the time you spend in your slot to know if you are facing this issue.

          Also remember that signal/slots connections are synchronous by default, if you have a single thread.[/quote]

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adrien Leravat
            wrote on last edited by
            #5

            Ok,

            I can't think of anything causing such a problem, except a high cpu usage, preventing the event loop from running normally. Or something blocking the execution before you update your value.

            Logging some information with a timestamp will help you understand what's really happening.

            Adeneo Embedded - www.adeneo-embedded.com

            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