7#include <private/qapplication_p.h>
8#include <private/qwidget_p.h>
11#include <private/qmenu_p.h>
13#if QT_CONFIG(graphicsview)
14#include "qgraphicswidget.h"
20QActionPrivate *QApplicationPrivate::createActionPrivate()
const
22 return new QtWidgetsActionPrivate;
25QtWidgetsActionPrivate::~QtWidgetsActionPrivate() =
default;
28void QtWidgetsActionPrivate::destroy()
31 const auto objects = associatedObjects;
32 const auto end = objects.crend();
33 for (
auto it = objects.crbegin(); it != end; ++it) {
34 QObject *object = *it;
35 if (QWidget *widget = qobject_cast<QWidget*>(object))
36 widget->removeAction(q);
37#if QT_CONFIG(graphicsview)
38 else if (QGraphicsWidget *graphicsWidget = qobject_cast<QGraphicsWidget*>(object))
39 graphicsWidget->removeAction(q);
44#if QT_CONFIG(shortcut)
45QShortcutMap::ContextMatcher QtWidgetsActionPrivate::contextMatcher()
const
47 return qWidgetShortcutContextMatcher;
52QObject *QtWidgetsActionPrivate::menu()
const
57void QtWidgetsActionPrivate::setMenu(QObject *menu)
60 QMenu *theMenu = qobject_cast<QMenu*>(menu);
61 Q_ASSERT_X(!menu || theMenu,
"QAction::setMenu",
62 "QAction::setMenu expects a QMenu* in widget applications");
64 m_menu->d_func()->setOverrideMenuAction(
nullptr);
67 m_menu->d_func()->setOverrideMenuAction(q);