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. Multiple QTimers or Multiple Connects to same QTimer
Qt 6.11 is out! See what's new in the release blog

Multiple QTimers or Multiple Connects to same QTimer

Scheduled Pinned Locked Moved General and Desktop
2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,

    I am on a development team of a new Qt application that requires several polling loops to: update status, update some objects on displays based on changes, read messages as they arrive, send requests to other computers, etc, etc. We have been trying to decide whether to use 4 QTimers, each at different intervals (1, 2, 5, 10 seconds) and connect maybe 5 slots to each, OR to use multiple QTimers, and end up with 20 QTImers firing, some at the same interval.

    Anybody have an opinion on the better way to go?

    Thanks in advance.
    pennylaney

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi, welcome to devnet

      It's hard to say which one is "better". My feeling is you won't see much difference one way or the other.
      Qt is really designed in a more action-reaction style. Although I don't know what your app is about I can say that any sort of polling is usually wasteful as it re-does a lot of the same work over and over.
      The more Qtish design is to respond to events and connect to signals - so do something in reaction to something: Update status when it changes, not in intervals. Update display when underlying data changes, not check for it periodically. Create message (or event) handlers instead of checking if some arrived and so on.
      All this is of course theoretical without a more detailed info.

      1 Reply Last reply
      1

      • Login

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