Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Design question for application using two QT timers
Forum Update on Monday, May 27th 2025

Design question for application using two QT timers

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 467 Views
  • 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.
  • S Offline
    S Offline
    saurabh162
    wrote on 1 Nov 2018, 13:12 last edited by
    #1

    Dear Developers,

    In my QT application I have:

    1. Main application which monitor signal from QT Button widget.
    2. Timer 1 which I want to use to calculate delay of different time period.
      This delay I will use between execution of different instructions in program
    3. Timer 2 I need to observe status of hardware key after every
      one second and take some steps in case hardware key is pressed.

    So my question are:

    Q) What is correct way to design this application ?
    Whether I should use multiple thread in my application ?
    First thread to run main application and Timer1 (used to calculate delay).
    Second thread to run Timer 2, I am using to observe hardware key after every one second.

    Q) In case you recommend me that I can also achieve it using single thread application. Then what will happen if if

    1. I get signal from both QT Button widget and Timer 2 at same time? Whose slot will be executed first ?
    2. What will happen when I am in Button widget slot (approx have 10 second execution time) and I get signal from timer 2 ? Whether
      execution of Button slot will be interrupted and whether I will go in Timer 2 Slot?
    3. I want slot of timer 2 should have higher priority than Button Slot ? Can you please suggest me, how can I
      achieve it ?

    Thank you much. Kindly inform me if you need any information from me.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eeli K
      wrote on 1 Nov 2018, 16:41 last edited by
      #2

      First - without threads is usually easier to make without problems. Go threading only if needed.

      Do you understand that a user interface is already kind of asynchronous, so that the user can do different things? Adding timers just adds more possible events. Timer events (signals) are handled just like UI signals. Whatever comes first is served by the system. Whatever you do in a slot takes as much time as it takes and without threads nothing else is done at the same time. The UI doesn't respond while your slot is executed. The same thing happens with timers. If the executing the slot takes much time you either have locked UI or you have to create a thread.

      So, it depends on how much time is spent executing the slot which receives the timer's signal. If it's almost instantaneous you probably don't have to care.

      1 Reply Last reply
      4
      • S Offline
        S Offline
        saurabh162
        wrote on 2 Nov 2018, 09:49 last edited by saurabh162 11 Feb 2018, 11:02
        #3

        Hello Eeli K,

        Thank you very much for your quick reply. I think your answer has solved my query.

        thanks :)

        1 Reply Last reply
        0

        1/3

        1 Nov 2018, 13:12

        • Login

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