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. [Solved] How can i call two slot using timer alternately?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How can i call two slot using timer alternately?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.6k 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    I have two slot mousepress() and mouserelease(). I want when i will call timer the two slot should be called alternately not once at a time, so that i can visualize difference between mousepress and mouserelease while running the timer.

    Pratik Agrawal

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on last edited by
      #2

      If i understand you correctly every mousepress() should be followed by mouserelease() in a certain amount of time. So you can just create additional timer in mousepress() and connect mouserelease() to it.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        Mr. p-himik Did you want to say i have to use two timer?

        Pratik Agrawal

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kimbs
          wrote on last edited by
          #4

          //put this at the bottom of the mousepress slot
          @QTimer::singleshot(1000,this,SLOT(mouserelease()));@

          //and this at the bottom of the mouserelease slot
          @QTimer::singleshot(1000,this,SLOT(mousepress()));@

          and then call one of the slots.

          This should make a call to the mousepress() slot trigger a call to the mouserelease() slot 1 second later and vice versa.

          1 Reply Last reply
          0
          • AlicemirrorA Offline
            AlicemirrorA Offline
            Alicemirror
            wrote on last edited by
            #5

            I think that a faster way maybe a single function with a flag. You should only set the negation of the flag inside the slot and fire it every timer trigger. Then the flag indicate the way the slot function should follow.

            Enrico Miglino (aka Alicemirror)
            Balearic Dynamics
            Islas Baleares, Ibiza (Spain)
            www.balearicdynamics.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