Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qaction_widgets.cpp
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qaction.h"
6
7
#
include
<
private
/
qapplication_p
.
h
>
8
#
include
<
private
/
qwidget_p
.
h
>
9
#
include
"qaction_widgets_p.h"
10
#
if
QT_CONFIG
(
menu
)
11
#
include
<
private
/
qmenu_p
.
h
>
12
#
endif
13
#
if
QT_CONFIG
(
graphicsview
)
14
#
include
"qgraphicswidget.h"
15
#
endif
16
17
18
QT_BEGIN_NAMESPACE
19
20
QActionPrivate *QApplicationPrivate::createActionPrivate()
const
21
{
22
return
new
QtWidgetsActionPrivate;
23
}
24
25
QtWidgetsActionPrivate::~QtWidgetsActionPrivate() =
default
;
26
27
// we can't do this in the destructor, as it would only be called by ~QObject
28
void
QtWidgetsActionPrivate::destroy()
29
{
30
Q_Q(QAction);
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);
40
#
endif
41
}
42
}
43
44
#
if
QT_CONFIG
(
shortcut
)
45
QShortcutMap::ContextMatcher QtWidgetsActionPrivate::contextMatcher()
const
46
{
47
return
qWidgetShortcutContextMatcher;
48
}
49
#
endif
50
51
#
if
QT_CONFIG
(
menu
)
52
QObject *QtWidgetsActionPrivate::menu()
const
53
{
54
return
m_menu;
55
}
56
57
void
QtWidgetsActionPrivate::setMenu(QObject *menu)
58
{
59
Q_Q(QAction);
60
QMenu *theMenu = qobject_cast<QMenu*>(menu);
61
Q_ASSERT_X(!menu || theMenu,
"QAction::setMenu"
,
62
"QAction::setMenu expects a QMenu* in widget applications"
);
63
if
(m_menu)
64
m_menu->d_func()->setOverrideMenuAction(
nullptr
);
//we reset the default action of any previous menu
65
m_menu = theMenu;
66
if
(m_menu)
67
m_menu->d_func()->setOverrideMenuAction(q);
68
sendDataChanged();
69
}
70
#
endif
// QT_CONFIG(menu)
71
72
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
widgets
kernel
qaction_widgets.cpp
Generated on
for Qt by
1.18.0