Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickcombobox_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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKCOMBOBOX_P_H
6#define QQUICKCOMBOBOX_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qloggingcategory.h>
20#include <QtQmlModels/private/qtqmlmodels-config_p.h>
21#include <QtQuickTemplates2/private/qquickcontrol_p.h>
22
24
26
28
29class QValidator;
30class QQuickPopup;
31class QQmlInstanceModel;
33class QQmlComponent;
34
35class Q_QUICKTEMPLATES2_EXPORT QQuickComboBox : public QQuickControl
36{
37 Q_OBJECT
38 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
39 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
40 Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
41 Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL)
42 Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
43 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
44 Q_PROPERTY(QString currentText READ currentText NOTIFY currentTextChanged FINAL)
45 Q_PROPERTY(QString displayText READ displayText WRITE setDisplayText RESET resetDisplayText NOTIFY displayTextChanged FINAL)
46 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
47 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
48 Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
49 Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
50 // 2.1 (Qt 5.8)
51 Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL REVISION(2, 1))
52 // 2.2 (Qt 5.9)
53 Q_PROPERTY(bool down READ isDown WRITE setDown RESET resetDown NOTIFY downChanged FINAL REVISION(2, 2))
54 Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL REVISION(2, 2))
55 Q_PROPERTY(QString editText READ editText WRITE setEditText RESET resetEditText NOTIFY editTextChanged FINAL REVISION(2, 2))
56#if QT_CONFIG(validator)
57 Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL REVISION(2, 2))
58#endif
59 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION(2, 2))
60 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION(2, 2))
61 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged FINAL REVISION(2, 2))
62 // 2.5 (Qt 5.12)
63 Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION(2, 5))
64 Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION(2, 5))
65 Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,indicator,popup")
66 // 2.14 (Qt 5.14)
67 Q_PROPERTY(QVariant currentValue READ currentValue WRITE setCurrentValue NOTIFY currentValueChanged FINAL REVISION(2, 14))
68 Q_PROPERTY(QString valueRole READ valueRole WRITE setValueRole NOTIFY valueRoleChanged FINAL REVISION(2, 14))
69 // 2.15 (Qt 5.15)
70 Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse NOTIFY selectTextByMouseChanged FINAL REVISION(2, 15))
71 // 6.0 (Qt 6.0)
72 Q_PROPERTY(ImplicitContentWidthPolicy implicitContentWidthPolicy READ implicitContentWidthPolicy
73 WRITE setImplicitContentWidthPolicy NOTIFY implicitContentWidthPolicyChanged FINAL REVISION(6, 0))
74 QML_NAMED_ELEMENT(ComboBox)
75 QML_ADDED_IN_VERSION(2, 0)
76
77public:
78 explicit QQuickComboBox(QQuickItem *parent = nullptr);
79 ~QQuickComboBox();
80
81 int count() const;
82
83 QVariant model() const;
84 void setModel(const QVariant &model);
85 QQmlInstanceModel *delegateModel() const;
86
87 bool isPressed() const;
88 void setPressed(bool pressed);
89
90 int highlightedIndex() const;
91
92 int currentIndex() const;
93 void setCurrentIndex(int index);
94
95 QString currentText() const;
96
97 QString displayText() const;
98 void setDisplayText(const QString &text);
99 void resetDisplayText();
100
101 QString textRole() const;
102 void setTextRole(const QString &role);
103
104 QString valueRole() const;
105 void setValueRole(const QString &role);
106
107 QQmlComponent *delegate() const;
108 void setDelegate(QQmlComponent *delegate);
109
110 QQuickItem *indicator() const;
111 void setIndicator(QQuickItem *indicator);
112
113 QQuickPopup *popup() const;
114 void setPopup(QQuickPopup *popup);
115
116 Q_INVOKABLE QString textAt(int index) const;
117 Q_INVOKABLE int find(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly) const;
118
119 // 2.1 (Qt 5.8)
120 bool isFlat() const;
121 void setFlat(bool flat);
122
123 // 2.2 (Qt 5.9)
124 bool isDown() const;
125 void setDown(bool down);
126 void resetDown();
127
128 bool isEditable() const;
129 void setEditable(bool editable);
130
131 QString editText() const;
132 void setEditText(const QString &text);
133 void resetEditText();
134
135#if QT_CONFIG(validator)
136 QValidator *validator() const;
137 void setValidator(QValidator *validator);
138#endif
139
140 Qt::InputMethodHints inputMethodHints() const;
141 void setInputMethodHints(Qt::InputMethodHints hints);
142
143 bool isInputMethodComposing() const;
144 bool hasAcceptableInput() const;
145
146 // 2.5 (Qt 5.12)
147 qreal implicitIndicatorWidth() const;
148 qreal implicitIndicatorHeight() const;
149
150 // 2.14 (Qt 5.14)
151 QVariant currentValue() const;
152 Q_REVISION(6, 10) void setCurrentValue(const QVariant &value);
153 Q_REVISION(2, 14) Q_INVOKABLE QVariant valueAt(int index) const;
154 Q_REVISION(2, 14) Q_INVOKABLE int indexOfValue(const QVariant &value) const;
155
156 // 2.15 (Qt 5.15)
157 bool selectTextByMouse() const;
158 void setSelectTextByMouse(bool canSelect);
159
160 // 6.0 (Qt 6.0)
161 enum ImplicitContentWidthPolicy {
162 ContentItemImplicitWidth,
163 WidestText,
164 WidestTextWhenCompleted
165 };
166 Q_ENUM(ImplicitContentWidthPolicy)
167
168 ImplicitContentWidthPolicy implicitContentWidthPolicy() const;
169 void setImplicitContentWidthPolicy(ImplicitContentWidthPolicy policy);
170
171public Q_SLOTS:
172 void incrementCurrentIndex();
173 void decrementCurrentIndex();
174 Q_REVISION(2, 2) void selectAll();
175
176Q_SIGNALS:
177 void activated(int index);
178 void highlighted(int index);
179 void countChanged();
180 void modelChanged();
181 void delegateModelChanged();
182 void pressedChanged();
183 void highlightedIndexChanged();
184 void currentIndexChanged();
185 void currentTextChanged();
186 void displayTextChanged();
187 void textRoleChanged();
188 void delegateChanged();
189 void indicatorChanged();
190 void popupChanged();
191 // 2.1 (Qt 5.8)
192 Q_REVISION(2, 1) void flatChanged();
193 // 2.2 (Qt 5.9)
194 Q_REVISION(2, 2) void accepted();
195 Q_REVISION(2, 2) void downChanged();
196 Q_REVISION(2, 2) void editableChanged();
197 Q_REVISION(2, 2) void editTextChanged();
198#if QT_CONFIG(validator)
199 Q_REVISION(2, 2) void validatorChanged();
200#endif
201 Q_REVISION(2, 2) void inputMethodHintsChanged();
202 Q_REVISION(2, 2) void inputMethodComposingChanged();
203 Q_REVISION(2, 2) void acceptableInputChanged();
204 // 2.5 (Qt 5.12)
205 Q_REVISION(2, 5) void implicitIndicatorWidthChanged();
206 Q_REVISION(2, 5) void implicitIndicatorHeightChanged();
207 // 2.14 (Qt 5.14)
208 Q_REVISION(2, 14) void valueRoleChanged();
209 Q_REVISION(2, 14) void currentValueChanged();
210 // 2.15 (Qt 5.15)
211 Q_REVISION(2, 15) void selectTextByMouseChanged();
212 // 6.0 (Qt 6.0)
213 Q_REVISION(6, 0) void implicitContentWidthPolicyChanged();
214
215protected:
216 bool eventFilter(QObject *object, QEvent *event) override;
217 void focusInEvent(QFocusEvent *event) override;
218 void focusOutEvent(QFocusEvent *event) override;
219#if QT_CONFIG(im)
220 void inputMethodEvent(QInputMethodEvent *event) override;
221#endif
222 void keyPressEvent(QKeyEvent *event) override;
223 void keyReleaseEvent(QKeyEvent *event) override;
224#if QT_CONFIG(wheelevent)
225 void wheelEvent(QWheelEvent *event) override;
226#endif
227 bool event(QEvent *e) override;
228
229 void componentComplete() override;
230 void itemChange(ItemChange change, const ItemChangeData &value) override;
231 void fontChange(const QFont &newFont, const QFont &oldFont) override;
232 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
233 void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
234
235 QFont defaultFont() const override;
236
237#if QT_CONFIG(accessibility)
238 QAccessible::Role accessibleRole() const override;
239 void accessibilityActiveChanged(bool active) override;
240#endif
241
242private:
243 Q_DISABLE_COPY(QQuickComboBox)
244 Q_DECLARE_PRIVATE(QQuickComboBox)
245};
246
247QT_END_NAMESPACE
248
249#endif // QQUICKCOMBOBOX_P_H
QQuickComboBoxDelegateModel(QQuickComboBox *combo)
QVariant variantValue(int index, const QString &role) override
void itemDestroyed(QQuickItem *item) override
bool handleRelease(const QPointF &point, ulong timestamp) override
CurrentElementCriteria currentElementCriteria
QQuickDeferredPointer< QQuickPopup > popup
qreal calculateWidestTextWidth() const
static void hideOldPopup(QQuickPopup *popup)
void setInputMethodHints(Qt::InputMethodHints hints, bool force=false)
void setHighlightedIndex(int index, Highlighting highlight)
void createdItem(int index, QObject *object)
QString effectiveTextRole() const
virtual qreal getContentWidth() const override
void keySearch(const QString &text)
void handleUngrab() override
int match(int start, const QString &text, Qt::MatchFlags flags) const
QPalette defaultPalette() const override
bool handleMove(const QPointF &point, ulong timestamp) override
QQmlInstanceModel * delegateModel
void itemImplicitHeightChanged(QQuickItem *item) override
void togglePopup(bool accept)
void executePopup(bool complete=false)
void itemImplicitWidthChanged(QQuickItem *item) override
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void executeIndicator(bool complete=false)
QQuickDeferredPointer< QQuickItem > indicator
void hidePopup(bool accept)
void setCurrentIndex(int index)
QLazilyAllocated< ExtraData > extra
std::optional< QPointer< QObject > > qobjectModelGuard
bool handlePress(const QPointF &point, ulong timestamp) override
void setCurrentItemAtIndex(int, Activation activate)
bool isValidIndex(int index) const
QString tryComplete(const QString &inputText)
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher)
QT_REQUIRE_CONFIG(qml_delegate_model)
static QString popupName()
Qt::InputMethodHints inputMethodHints