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
qquickmenu_p.h
Go to the documentation of this file.
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 QQUICKMENU_P_H
5#define QQUICKMENU_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 <QtQml/qqmllist.h>
19#include <QtQml/qqml.h>
20#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
21
22#include "qquickpopup_p.h"
23#include <QtQuickTemplates2/private/qquickicon_p.h>
24
25QT_REQUIRE_CONFIG(qml_object_model);
26
28
29class QQuickAction;
30class QQmlComponent;
31class QQuickMenuItem;
33
34class Q_QUICKTEMPLATES2_EXPORT QQuickMenu : public QQuickPopup
35{
37 Q_PROPERTY(QVariant contentModel READ contentModel CONSTANT FINAL)
38 Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL)
39 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
40 // 2.3 (Qt 5.10)
41 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL REVISION(2, 3))
42 Q_PROPERTY(bool cascade READ cascade WRITE setCascade RESET resetCascade NOTIFY cascadeChanged FINAL REVISION(2, 3))
43 Q_PROPERTY(qreal overlap READ overlap WRITE setOverlap NOTIFY overlapChanged FINAL REVISION(2, 3))
44 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL REVISION(2, 3))
45 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL REVISION(2, 3))
46 // 6.5 (Qt 6.5)
47 Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(6, 5))
48 Q_CLASSINFO("DefaultProperty", "contentData")
51
52public:
53 explicit QQuickMenu(QObject *parent = nullptr);
54 ~QQuickMenu();
55
56 Q_INVOKABLE QQuickItem *itemAt(int index) const;
58 Q_INVOKABLE void insertItem(int index, QQuickItem *item);
59 Q_INVOKABLE void moveItem(int from, int to);
60 Q_INVOKABLE void removeItem(QQuickItem *item);
61
62 QVariant contentModel() const;
63 QQmlListProperty<QObject> contentData();
64
65 QString title() const;
66 void setTitle(const QString &title);
67
68 QQuickIcon icon() const;
69 void setIcon(const QQuickIcon &icon);
70
71 bool cascade() const;
72 void setCascade(bool cascade);
73 void resetCascade();
74
75 qreal overlap() const;
76 void setOverlap(qreal overlap);
77
78 QQmlComponent *delegate() const;
79 void setDelegate(QQmlComponent *delegate);
80
81 int currentIndex() const;
82 void setCurrentIndex(int index);
83
84 // 2.3 (Qt 5.10)
85 int count() const;
86 Q_REVISION(2, 3) Q_INVOKABLE QQuickItem *takeItem(int index);
87
88 Q_REVISION(2, 3) Q_INVOKABLE QQuickMenu *menuAt(int index) const;
90 Q_REVISION(2, 3) Q_INVOKABLE void insertMenu(int index, QQuickMenu *menu);
91 Q_REVISION(2, 3) Q_INVOKABLE void removeMenu(QQuickMenu *menu);
92 Q_REVISION(2, 3) Q_INVOKABLE QQuickMenu *takeMenu(int index);
93
94 Q_REVISION(2, 3) Q_INVOKABLE QQuickAction *actionAt(int index) const;
95 Q_REVISION(2, 3) Q_INVOKABLE void addAction(QQuickAction *action);
96 Q_REVISION(2, 3) Q_INVOKABLE void insertAction(int index, QQuickAction *action);
97 Q_REVISION(2, 3) Q_INVOKABLE void removeAction(QQuickAction *action);
98 Q_REVISION(2, 3) Q_INVOKABLE QQuickAction *takeAction(int index);
99
100 void popup(QQuickItem *menuItem = nullptr);
101 void popup(const QPointF &pos, QQuickItem *menuItem = nullptr);
102
104 Q_REVISION(2, 3) Q_INVOKABLE void dismiss();
105
106protected:
107 void componentComplete() override;
108 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
109 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
110 void keyPressEvent(QKeyEvent *event) override;
111
113 void titleChanged(const QString &title);
114 // 2.3 (Qt 5.10)
115 Q_REVISION(2, 3) void countChanged();
116 Q_REVISION(2, 3) void cascadeChanged(bool cascade);
117 Q_REVISION(2, 3) void overlapChanged();
118 Q_REVISION(2, 3) void delegateChanged();
119 Q_REVISION(2, 3) void currentIndexChanged();
120 // 6.5 (Qt 6.5)
121 Q_REVISION(6, 5) void iconChanged(const QQuickIcon &icon);
122
123protected:
124 void timerEvent(QTimerEvent *event) override;
125
126 QFont defaultFont() const override;
127
128#if QT_CONFIG(accessibility)
129 QAccessible::Role accessibleRole() const override;
130#endif
131
132private:
133 Q_DISABLE_COPY(QQuickMenu)
134 Q_DECLARE_PRIVATE(QQuickMenu)
135};
136
138
139#endif // QQUICKMENU_P_H
\reentrant
Definition qfont.h:22
The QKeyEvent class describes a key event.
Definition qevent.h:424
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQmlComponent class encapsulates a QML component definition.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qcoreevent.h:366
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
struct _cl_event * event
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define Q_INVOKABLE
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit
QString title
[35]
scene addItem(form)
QGraphicsItem * item
myAction setIcon(SomeIcon)
g setTitle("&User information")
[0]
QMenu menu
[5]
menubar addMenu(fileMenu)
[0]
QJSValueList args