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 QtimerEvent handling
QtWS25 Last Chance

Multiple QtimerEvent handling

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 810 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.
  • Q Offline
    Q Offline
    qt_ankit_developer
    wrote on 14 Dec 2018, 12:27 last edited by
    #1

    Dear sir,
    I have used single Q TimerEvent to call a timer slot continuously in given specific time. but in My application I have to call multiple Q timer events from a single push button .
    so please help me for firing of multiple QTimerevent .
    and how to kill by using their QTimerId of every Q timer event;

    R J 2 Replies Last reply 14 Dec 2018, 12:40
    0
    • Q qt_ankit_developer
      14 Dec 2018, 12:27

      Dear sir,
      I have used single Q TimerEvent to call a timer slot continuously in given specific time. but in My application I have to call multiple Q timer events from a single push button .
      so please help me for firing of multiple QTimerevent .
      and how to kill by using their QTimerId of every Q timer event;

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 14 Dec 2018, 12:40 last edited by
      #2

      @qt_ankit_developer said in Multiple QtimerEvent handling:

      I have used single Q TimerEvent to call a timer slot continuously in given specific time. but in My application I have to call multiple Q timer events from a single push button .

      do you create the timer events manually?! o.O
      If so, why??

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Q qt_ankit_developer
        14 Dec 2018, 12:27

        Dear sir,
        I have used single Q TimerEvent to call a timer slot continuously in given specific time. but in My application I have to call multiple Q timer events from a single push button .
        so please help me for firing of multiple QTimerevent .
        and how to kill by using their QTimerId of every Q timer event;

        J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 14 Dec 2018, 12:43 last edited by
        #3

        @qt_ankit_developer
        to quote myself:

        @J.Hilk said in Q timer Event with timer id:

        @qt_ankit_developer
        even so @sierdzio is correct, a QTimer instance would be easier. Here is how you would do it via QTimerEvent:

        void myClass::startMyTimerEvent()
        {
            if (m_timerId == -1)
                m_timerId = startTimer(m_Timeout);
        }
         
        void myClass:: stopMyTimerEvent()
        {
            if (m_timerId != -1)
                killTimer(m_timerId);
            m_timerId = -1;
        }
        
        void myClass::timerEvent(QTimerEvent *event)
        {
           if(event->timerId() == m_timerId) {
               //do Stufff
               ....
              callMyFunction();
           }
        }
        

        instead of a single member variable, m_timerId use a QVector or QList of ints to store your ID's.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 14 Dec 2018, 13:37 last edited by
          #4

          I feel you should use the QTimer and be happy. You can refer my GIT see the example. timeEvent handling requires good boilerplate code.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0

          4/4

          14 Dec 2018, 13:37

          • Login

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