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.h | |
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.h')
-rw-r--r-- | src/widgets/widgets/qmenu.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 68481308fb..1b14263e6b 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -189,6 +189,8 @@ public: QAction *actionAt(const QPoint &) const; QAction *menuAction() const; + static QMenu *menuInAction(const QAction *action) + { return qobject_cast<QMenu *>(action->menuObject()); } QString title() const; void setTitle(const QString &title); |