Hello Qt Centre,

I have an application that is split into two parts: the GUI, and a Manager object. Manager is a QObject with several slots, and when the slots are invoked, they run in a separate thread. QObject::moveToThread() makes this very easy.

Buttons on the GUI are connected to slots on the Manager. The Manager controls a piece of hardware (I don't think the specifics here are too important - what is important is the slots do not execute instantaneously).

The essence of my problem is that my users have a tendency to mash the buttons faster than the slots can execute (faster than the hardware's motors can move), causing the Manager object to repeatedly invoke a slot. This is rarely what the users want, and ultimately they have to wait for the hardware to finish performing all their unwanted actions before they can start being productive again.

OK, so the solution is simple, right? Just tell the users to not do that, problem solved! If only it were that easy

My solution up until this point has been for the Manager object to emit a "I am busy" signal to the GUI. A slot on the GUI loops through most of the widgets in the GUI and disables them. Then when the Manager is done executing, it emits a signal indicating that it is not busy anymore, and the GUI turns all the widgets back on. This approach has worked for a while, but it is starting to be a bit of a maintenance burden: certain widgets need to be disabled for other reasons (hardware has entered a state where certain functionality is unavailable). The code for widget enabling/disabling is starting to smell bad. I am now in search of a cleaner solution to the button mashing problem.


Ideally, if a slot on the Manager is currently executing, additional signals connected to the slot will be ignored, or perhaps two or three signals would be queued, and subsequent signals discarded until the slot is done executing.

I've done a bit of searching but I have not been able to articulate my problem very well to Google (I hope I have done an OK job of describing it here...)

Qt::BlockingQueuedConnection does not do what I need.

Have I just designed my application badly?
Is there a name for a design pattern that I can try to understand, that either does not have this problem, or solves it elegantly?
Any insight or guidance would be greatly appreciated.

Thanks in advance