I'm planning on using qActions for use globally in my application. The idea is to have an action to be available at any level in the widget parent/child hierarchy.
Let's say I have the following GUI:
+--------------+
| +----------+ |
| | +----+ | |
| | | W2 | | |
| | +----+ | |
| | W1 | |
| +----------+ |
| MainWindow |
+--------------+
W2 has a QPushButton which I want to use with a QAction defined in MainWindow. So the question is: What is the recommended way of working with QActions in multiple level hierarchy of widgets?
Here are my approaches:
Define the actions in a MainWindow singleton, and access it from W2 to add the qaction to the QPushButton.
Define the actions in MainWindow and add them to W1, which in turn would add the qaction to W2, which in turn would add the action to the QPushButton (I don't like this one).
Create a Delegate singleton class to hold qactions and access it from MainWindow to make the global connections of qactions' triggers to the backend (model), and also access it from W2 to add the action wanted to the QPushButton.
Thanks