[Solved] How can i call two slot using timer alternately?
-
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.
-
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.
-
Mr. p-himik Did you want to say i have to use two timer?
-
//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.
-
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.