Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmenubar.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
4#ifndef QMENUBAR_H
5#define QMENUBAR_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qmenu.h>
9
11
13
14class QMenuBarPrivate;
16class QWindowsStyle;
18
19class Q_WIDGETS_EXPORT QMenuBar : public QWidget
20{
22
23 Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
24 Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
25
26public:
27 explicit QMenuBar(QWidget *parent = nullptr);
28 ~QMenuBar();
29
30 using QWidget::addAction;
31#if QT_WIDGETS_REMOVED_SINCE(6, 3)
32 QAction *addAction(const QString &text);
33 QAction *addAction(const QString &text, const QObject *receiver, const char* member);
34#endif
35
37 QMenu *addMenu(const QString &title);
38 QMenu *addMenu(const QIcon &icon, const QString &title);
39
40
41 QAction *addSeparator();
42 QAction *insertSeparator(QAction *before);
43
44 QAction *insertMenu(QAction *before, QMenu *menu);
45
46 void clear();
47
48 QAction *activeAction() const;
49 void setActiveAction(QAction *action);
50
51 void setDefaultUp(bool);
52 bool isDefaultUp() const;
53
54 QSize sizeHint() const override;
55 QSize minimumSizeHint() const override;
56 int heightForWidth(int) const override;
57
58 QRect actionGeometry(QAction *) const;
59 QAction *actionAt(const QPoint &) const;
60
61 void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
62 QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
63
64#if defined(Q_OS_MACOS) || defined(Q_QDOC)
65 NSMenu* toNSMenu();
66#endif
67
68 bool isNativeMenuBar() const;
69 void setNativeMenuBar(bool nativeMenuBar);
70 QPlatformMenuBar *platformMenuBar();
71public Q_SLOTS:
72 void setVisible(bool visible) override;
73
75 void triggered(QAction *action);
76 void hovered(QAction *action);
77
78protected:
79 void changeEvent(QEvent *) override;
80 void keyPressEvent(QKeyEvent *) override;
81 void mouseReleaseEvent(QMouseEvent *) override;
82 void mousePressEvent(QMouseEvent *) override;
83 void mouseMoveEvent(QMouseEvent *) override;
84 void leaveEvent(QEvent *) override;
85 void paintEvent(QPaintEvent *) override;
86 void resizeEvent(QResizeEvent *) override;
87 void actionEvent(QActionEvent *) override;
88 void focusOutEvent(QFocusEvent *) override;
89 void focusInEvent(QFocusEvent *) override;
90 void timerEvent(QTimerEvent *) override;
91 bool eventFilter(QObject *, QEvent *) override;
92 bool event(QEvent *) override;
93 virtual void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
94
95private:
96 Q_DECLARE_PRIVATE(QMenuBar)
97 Q_DISABLE_COPY(QMenuBar)
98 Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
99 Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
100 Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
101 Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
102
103 friend class QMenu;
104 friend class QMenuPrivate;
105 friend class QWindowsStyle;
106};
107
109
110#endif // QMENUBAR_H
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QMenuBar class provides a horizontal menu bar.
Definition qmenubar.h:20
void hovered(QAction *action)
This signal is emitted when a menu action is highlighted; action is the action that caused the event ...
void triggered(QAction *action)
This signal is emitted when an action in a menu belonging to this menubar is triggered as a result of...
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\variable QStyleOptionProgressBar::minimum
\inmodule QtCore
Definition qcoreevent.h:366
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
b clear()
QString text
Combined button and popup list for selecting options.
@ TopRightCorner
GLfloat GLfloat GLfloat w
[0]
struct _cl_event * event
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
#define explicit
QString title
[35]
QMenu menu
[5]
menubar addMenu(fileMenu)
[0]