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
qquickspinbox_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 QQUICKSPINBOX_P_H
6#define QQUICKSPINBOX_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 <QtQuickTemplates2/private/qquickabstractspinbox_p.h>
20#include <QtQuickTemplates2/private/qquickcontrol_p.h>
21#include <QtQml/qjsvalue.h>
22
23QT_BEGIN_NAMESPACE
24
25class QValidator;
27class QQuickIndicatorButton;
28
29class Q_QUICKTEMPLATES2_EXPORT QQuickSpinBox : public QQuickControl,
30 public QQuickAbstractSpinBox<QQuickSpinBox, int>
31{
32 Q_OBJECT
33 Q_PROPERTY(int from READ from WRITE setFrom NOTIFY fromChanged FINAL)
34 Q_PROPERTY(int to READ to WRITE setTo NOTIFY toChanged FINAL)
35 Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged FINAL)
36 Q_PROPERTY(int stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
37 Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL)
38 Q_PROPERTY(bool live READ isLive WRITE setLive NOTIFY liveChanged FINAL REVISION(6, 6))
39
40#if QT_CONFIG(validator)
41 Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL)
42#endif
43 Q_PROPERTY(QJSValue textFromValue READ textFromValue WRITE setTextFromValue NOTIFY textFromValueChanged FINAL)
44 Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText NOTIFY valueFromTextChanged FINAL)
45 Q_PROPERTY(QQuickIndicatorButton *up READ up CONSTANT FINAL)
46 Q_PROPERTY(QQuickIndicatorButton *down READ down CONSTANT FINAL)
47 // 2.2 (Qt 5.9)
48 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION(2, 2))
49 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION(2, 2))
50 // 2.3 (Qt 5.10)
51 Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL REVISION(2, 3))
52 // 2.4 (Qt 5.11)
53 Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged FINAL REVISION(2, 4))
54 QML_NAMED_ELEMENT(SpinBox)
55 QML_ADDED_IN_VERSION(2, 0)
56
57public:
58 explicit QQuickSpinBox(QQuickItem *parent = nullptr);
59 ~QQuickSpinBox();
60
61 void setFrom(int from);
62
63 void setTo(int to);
64
65 void setValue(int value);
66
67 void setStepSize(int step);
68
69 bool isLive() const;
70 void setLive(bool live);
71
72 QJSValue textFromValue() const;
73
74 QJSValue valueFromText() const;
75
76 void setWrap(bool wrap);
77
78Q_SIGNALS:
79 void fromChanged();
80 void toChanged();
81 void valueChanged();
82 void stepSizeChanged();
83 void editableChanged();
84 Q_REVISION(6, 6) void liveChanged();
85#if QT_CONFIG(validator)
86 void validatorChanged();
87#endif
88 void textFromValueChanged();
89 void valueFromTextChanged();
90 // 2.2 (Qt 5.9)
91 Q_REVISION(2, 2) void valueModified();
92 Q_REVISION(2, 2) void inputMethodHintsChanged();
93 Q_REVISION(2, 2) void inputMethodComposingChanged();
94 // 2.3 (Qt 5.10)
95 Q_REVISION(2, 3) void wrapChanged();
96 // 2.4 (Qt 5.11)
97 Q_REVISION(2, 4) void displayTextChanged();
98
99protected:
100 void focusInEvent(QFocusEvent *event) override
101 {
102 QQuickControl::focusInEvent(event);
103 handleFocusInEvent(event);
104 }
105 void hoverEnterEvent(QHoverEvent *event) override
106 {
107 QQuickControl::hoverEnterEvent(event);
108 handleHoverEnterEvent(event);
109 }
110 void hoverMoveEvent(QHoverEvent *event) override
111 {
112 QQuickControl::hoverMoveEvent(event);
113 handleHoverMoveEvent(event);
114 }
115 void hoverLeaveEvent(QHoverEvent *event) override
116 {
117 QQuickControl::hoverLeaveEvent(event);
118 handleHoverLeaveEvent(event);
119 }
120 void keyPressEvent(QKeyEvent *event) override
121 {
122 QQuickControl::keyPressEvent(event);
123 handleKeyPressEvent(event);
124 }
125 void keyReleaseEvent(QKeyEvent *event) override
126 {
127 QQuickControl::keyReleaseEvent(event);
128 handleKeyReleaseEvent(event);
129 }
130 void timerEvent(QTimerEvent *event) override
131 {
132 QQuickControl::timerEvent(event);
133 handleTimerEvent(event);
134 }
135#if QT_CONFIG(wheelevent)
136 void wheelEvent(QWheelEvent *event) override
137 {
138 QQuickControl::wheelEvent(event);
139 handleWheelEvent(event);
140 }
141#endif
142 void classBegin() override
143 {
144 QQuickControl::classBegin();
145 handleClassBegin();
146 }
147 void componentComplete() override
148 {
149 QQuickControl::componentComplete();
150 handleComponentComplete();
151 }
152 void itemChange(ItemChange change, const ItemChangeData &value) override
153 {
154 QQuickControl::itemChange(change, value);
155 handleItemChange(change, value);
156 }
157 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
158 void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override
159 {
160 QQuickControl::localeChange(newLocale, oldLocale);
161 handleLocaleChange();
162 }
163 QFont defaultFont() const override
164 {
165 return QQuickAbstractSpinBox<QQuickSpinBox, int>::defaultFont();
166 }
167#if QT_CONFIG(accessibility)
168 QAccessible::Role accessibleRole() const override
169 {
170 return QQuickAbstractSpinBox<QQuickSpinBox, int>::accessibleRole();
171 }
172 void accessibilityActiveChanged(bool active) override
173 {
174 QQuickControl::accessibilityActiveChanged(active);
175 handleAccessibilityActiveChanged(active);
176 }
177#endif
178
179private:
180 Q_DISABLE_COPY(QQuickSpinBox)
181 Q_DECLARE_PRIVATE(QQuickSpinBox)
182 friend class QQuickAbstractSpinBox<QQuickSpinBox, int>;
183 QQuickControlPrivate *d_base_func();
184 const QQuickControlPrivate *d_base_func() const;
185};
186
187QT_END_NAMESPACE
188
189#endif // QQUICKSPINBOX_P_H
Allows the user to select from a set of preset values.
int evaluateValueFromText(const QString &text) const
bool setValue(int newValue, bool wrap, ValueStatus modified) override
QString evaluateTextFromValue(int val) const
void updateValue() override
void updateDisplayText() override
Combined button and popup list for selecting options.