Extending QAction by emitting additional Signals
Extending QAction to provide a checked/unchecked signals
QAction can be set up to be checkable, that means that it will toggle its status between a checked and unchecked status. This is displayed, for instance, as a qpushbutton that remains pushed when clicked a first time. The problem with QAction is that it emits a single signal, triggered(bool), with the actual status of the action (if checked or not). This requires your slot to manually check the boolean flag to perform a specific behavior depending on the checked status. If you want your action to perform two different tasks without having to check the checked status of the action you can subclass the action implementing a couple of signals to emit events depending on the action internal status.
This can become very handy when you have got a set of actions that must be perform a different behavior when checked but must do all the same task when unchecked.
Source Code
The source code is really simple.
Here there is the header file:
and here the implementation of the class
Usage Example
The action can be used in the way a QAction is, for instance: