path: root/src/widgets/widgets/qmenu.cpp
diff options
authorVolker Hilsheimer <>2020-03-18 17:02:11 +0100
committerVolker Hilsheimer <>2020-03-29 11:18:57 +0100
commitbcaff2b06fc46fce8a3ae6d613c025c8d097229c (patch)
treefde5485241a96c5ea1222e8299b046fdea9084e6 /src/widgets/widgets/qmenu.cpp
parente3d01840656a07f17549864da163b67094c03c0e (diff)
Remove QGuiAction again and split QAction implementation up instead
Duplicating the number of classes is a high price to pay to be able to have some QAction functionality behave differently, or be only available in widgets applications. Instead, declare the entire API in QtGui in QAction* classes, and delegate the implementation of QtWidgets specific functionality to the private. The creation of the private is then delegated to the Q(Gui)ApplicationPrivate instance through a virtual factory function. Change some public APIs that are primarily useful for specialized tools such as Designer to operate on QObject* rather than QWidget*. APIs that depend on QtWidgets types have been turned into inline template functions, so that they are instantiated only at the caller side, where we can expect the respective types to be fully defined. This way, we only need to forward declare a few classes in the header, and don't need to generate any additional code for e.g. language bindings. Change-Id: Id0b27f9187652ec531a2e8b1b9837e82dc81625c Reviewed-by: Volker Hilsheimer <>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 23292062cb..e26f797501 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -41,6 +41,7 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include "qactiongroup.h"
#include "qdebug.h"
#include "qstyle.h"
#include "qevent.h"
@@ -198,7 +199,8 @@ void QMenuPrivate::init()
defaultMenuAction = menuAction = new QAction(q);
- menuAction->d_func()->menu = q;
+ menuAction->setMenu(q); // this calls setOverrideMenuAction
+ setOverrideMenuAction(nullptr);
QObject::connect(menuAction, &QAction::changed, [this] {
if (!tornPopup.isNull())
@@ -2244,7 +2246,7 @@ void QMenu::clear()
for(int i = 0; i < acts.size(); i++) {
- if (acts[i]->parent() == this && acts[i]->d_func()->widgets.isEmpty())
+ if (acts[i]->parent() == this && acts[i]->d_func()->associatedObjects.isEmpty())
delete acts[i];