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



  • 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.



  • 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



  • 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.



  • 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]



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.