How to trigger a slot after an interval
-
I wan to avoid the user to change the selection every time when they click a button.
Is there a way to make a slot to call after an interval like 2 secs? If the user has a new click action, then It can drop the previous call and make a new call from the slot? If possible, giving me an example would be better. Thank you very much.
-
@clementNg said in How to trigger a slot after an interval:
Is there a way to make a slot to call after an interval like 2 secs?
In principle, yes, you can use a
QTimer
for that. However, it does not sound like that is what you want. Your slot belongs on the clicked signal, not on a timer signal. Instead it is your job to save the time when the slot is clicked, and the next time it is clicked ignore it if it is within 2 seconds of the previous click. Or whatever it is you are saying you want to do/not do, using that approach.Or, perhaps you are saying you are wanting to: on click, don't act on it immediately, instead start a 2-second
QTimer
, and act on that when it expires, if user has not clicked something else.I can't tell exactly what you want from your description.