1// Copyright (C) 2017 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 QQUICKMENUBAR_P_H
5#define QQUICKMENUBAR_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTemplates2/private/qquickcontainer_p.h>
19
20QT_REQUIRE_CONFIG(quicktemplates2_container);
21
22QT_BEGIN_NAMESPACE
23
24class QQuickMenu;
25class QQuickMenuBarPrivate;
26
27class Q_QUICKTEMPLATES2_EXPORT QQuickMenuBar : public QQuickContainer
28{
29 Q_OBJECT
30 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
31 Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QQuickMenu> menus READ menus NOTIFY menusChanged FINAL)
32 Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL)
33 QML_NAMED_ELEMENT(MenuBar)
34 QML_ADDED_IN_VERSION(2, 3)
35
36public:
37 explicit QQuickMenuBar(QQuickItem *parent = nullptr);
38 ~QQuickMenuBar() override;
39
40 QQmlComponent *delegate() const;
41 void setDelegate(QQmlComponent *delegate);
42
43 Q_INVOKABLE QQuickMenu *menuAt(int index) const;
44 Q_INVOKABLE void addMenu(QQuickMenu *menu);
45 Q_INVOKABLE void insertMenu(int index, QQuickMenu *menu);
46 Q_INVOKABLE void removeMenu(QQuickMenu *menu);
47 Q_INVOKABLE QQuickMenu *takeMenu(int index);
48
49Q_SIGNALS:
50 void delegateChanged();
51 void menusChanged();
52
53protected:
54 bool eventFilter(QObject *object, QEvent *event) override;
55 void keyPressEvent(QKeyEvent *event) override;
56 void keyReleaseEvent(QKeyEvent *event) override;
57 void hoverLeaveEvent(QHoverEvent *event) override;
58
59 bool isContent(QQuickItem *item) const override;
60 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
61 void itemAdded(int index, QQuickItem *item) override;
62 void itemMoved(int index, QQuickItem *item) override;
63 void itemRemoved(int index, QQuickItem *item) override;
64
65 void componentComplete() override;
66
67 QFont defaultFont() const override;
68
69#if QT_CONFIG(accessibility)
70 QAccessible::Role accessibleRole() const override;
71#endif
72
73private:
74 Q_DISABLE_COPY(QQuickMenuBar)
75 Q_DECLARE_PRIVATE(QQuickMenuBar)
76};
77
78QT_END_NAMESPACE
79
80#endif // QQUICKMENUBAR_P_H
81

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/quicktemplates/qquickmenubar_p.h