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

Multiple QtimerEvent handling

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 902 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.
  • qt_ankit_developerQ Offline
    qt_ankit_developerQ Offline
    qt_ankit_developer
    wrote on 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;

    raven-worxR J.HilkJ 2 Replies Last reply
    0
    • qt_ankit_developerQ qt_ankit_developer

      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;

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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
      • qt_ankit_developerQ qt_ankit_developer

        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.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on 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
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on 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

          • Login

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