Results 1 to 20 of 48

Thread: Multiple timers in single Application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Multiple timers in single Application

    Then you have seriouly re-consider your structure / architectrue of using timers.

    1. Either simply the logic so that it can fit into the time
    or
    2. Try moving the heavy logic into a thread. (as other poster suggested)

    Some how I feel you can do this with using 6 timers or more, one important rule to follow is all the slots should complete with in time. Try re-structing your timers, and what they do.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  2. The following user says thank you to Santosh Reddy for this useful post:

    mahi6a1985 (22nd September 2012)

  3. #2
    Join Date
    Jun 2010
    Location
    Pretoria, South Africa
    Posts
    22
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple timers in single Application

    @mahi6a1985

    Do you really need 6 QTimers? I see from your code that there are two QTimers linked to the footer() slot.

    I would seriously consider moving your processing to different threads.

    When a QTimer emits the timeout signal, it gets put in the message queue and the slot is called by the event posting mechanism. Since all your QTimers are in the same thread, their timeout signals all get processed one after another.

    If, by chance, all the QTimers timeout at exactly the same time, then, the footer() slot will be called at least 925ms after update_HMIScrLvl4(). That's assuming that each of the slots instantaneously returned and called the subsequent timeout slot.

    I would suggest that you put each of your timer slots into its own thread, or group the processing by timeout interval. By this I mean that, because failure_display() and footer() are triggered every 250ms, their code could be executed in the same thread, if you like.

  4. The following user says thank you to Robbie for this useful post:

    mahi6a1985 (22nd September 2012)

Similar Threads

  1. Single Application Instance
    By BadKnees in forum Qt Programming
    Replies: 8
    Last Post: 4th November 2014, 14:57
  2. Multiple project files in a single directory
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 17th July 2008, 07:03
  3. Single QGLContext across multiple QGLWidgets
    By pseudosig in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2008, 23:13
  4. Single slot for multiple list boxes
    By Sheetal in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2008, 06:53
  5. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.