Reputation: 635
When QToolBar
and QDockWidget
widgets are used, they automatically generate a context menu which allows you to show/hide these dock and toolbar widgets (see the screenshot).
How can I get these context menu actions?
Usage example: E.g., I want to add the same actions (to show/hide docks and toolbars), to the "Window" QMenu
in the menu bar without manually repeating the previously mentioned context menu.
Upvotes: 1
Views: 1700
Reputation: 635
Found the answer.
The mentioned context menu which contains automatically generated actions to show/hide dock widgets and toolbars is actually handled by the QMainWindow
class. It has createPopupMenu()
method which generates this list.
So this is how to get the main window context menu actions:
QList<QAction *> actions = createPopupMenu()->actions();
Upvotes: 4