diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-10-25 14:27:00 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-11-01 23:22:55 +0100 |
commit | 35ddf3498859dc184456346f2b070fe94dabaf26 (patch) | |
tree | f91cb4beca451e1a49303230973592758cf711f5 /src/widgets/widgets/qmenu.cpp | |
parent | 6ab16d52d282b1a370cda3f0cf0827142250ac29 (diff) |
Add QMenu::menuInAction as a static helper
QAction::menu is deprecated, as it makes QAction (a QtGui class) depend
on QtWidgets. The template hack works, but shouldn't become a permanent
solution and is already deprecated.
To get the QMenu out of a QAction that contains it, add a static helper
to QMenu instead. QAction continues to store the menu pointer so that
we don't have to use a dynamic property or an associative container in
QMenu.
Change-Id: Ieb6a2b1900d2fc2f16dd5a4a8ab7da98604642d3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 74ac7e799c..5ecac2c7c6 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1053,6 +1053,16 @@ QAction *QMenu::menuAction() const } /*! + \fn static QMenu *QMenu::menuInAction(const QAction *action) + + Returns the menu contained by \a action, or \nullptr if \a action does not + contain a menu. + + In widget applications, actions that contain menus can be used to create menu + items with submenus, or inserted into toolbars to create buttons with popup menus. +*/ + +/*! \property QMenu::title \brief The title of the menu |