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
78public Q_SLOTS:
79 void increase() override;
80 void decrease() override;
81
82Q_SIGNALS:
83 void fromChanged();
84 void toChanged();
85 void valueChanged();
86 void stepSizeChanged();
87 void editableChanged();
88 Q_REVISION(6, 6) void liveChanged();
89#if QT_CONFIG(validator)
90 void validatorChanged();
91#endif
92 void textFromValueChanged();
93 void valueFromTextChanged();
94 // 2.2 (Qt 5.9)
95 Q_REVISION(2, 2) void valueModified();
96 Q_REVISION(2, 2) void inputMethodHintsChanged();
97 Q_REVISION(2, 2) void inputMethodComposingChanged();
98 // 2.3 (Qt 5.10)
99 Q_REVISION(2, 3) void wrapChanged();
100 // 2.4 (Qt 5.11)
101 Q_REVISION(2, 4) void displayTextChanged();
102
103protected:
104 void focusInEvent(QFocusEvent *event) override
105 {
106 QQuickControl::focusInEvent(event);
107 handleFocusInEvent(event);
108 }
109 void hoverEnterEvent(QHoverEvent *event) override
110 {
111 QQuickControl::hoverEnterEvent(event);
112 handleHoverEnterEvent(event);
113 }
114 void hoverMoveEvent(QHoverEvent *event) override
115 {
116 QQuickControl::hoverMoveEvent(event);
117 handleHoverMoveEvent(event);
118 }
119 void hoverLeaveEvent(QHoverEvent *event) override
120 {
121 QQuickControl::hoverLeaveEvent(event);
122 handleHoverLeaveEvent(event);
123 }
124 void keyPressEvent(QKeyEvent *event) override
125 {
126 QQuickControl::keyPressEvent(event);
127 handleKeyPressEvent(event);
128 }
129 void keyReleaseEvent(QKeyEvent *event) override
130 {
131 QQuickControl::keyReleaseEvent(event);
132 handleKeyReleaseEvent(event);
133 }
134 void timerEvent(QTimerEvent *event) override
135 {
136 QQuickControl::timerEvent(event);
137 handleTimerEvent(event);
138 }
139#if QT_CONFIG(wheelevent)
140 void wheelEvent(QWheelEvent *event) override
141 {
142 QQuickControl::wheelEvent(event);
143 handleWheelEvent(event);
144 }
145#endif
146 void classBegin() override
147 {
148 QQuickControl::classBegin();
149 handleClassBegin();
150 }
151 void componentComplete() override
152 {
153 QQuickControl::componentComplete();
154 handleComponentComplete();
155 }
156 void itemChange(ItemChange change, const ItemChangeData &value) override
157 {
158 QQuickControl::itemChange(change, value);
159 handleItemChange(change, value);
160 }
161 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
162 void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override
163 {
164 QQuickControl::localeChange(newLocale, oldLocale);
165 handleLocaleChange();
166 }
167 QFont defaultFont() const override
168 {
169 return QQuickAbstractSpinBox<QQuickSpinBox, int>::defaultFont();
170 }
171#if QT_CONFIG(accessibility)
172 QAccessible::Role accessibleRole() const override
173 {
174 return QQuickAbstractSpinBox<QQuickSpinBox, int>::accessibleRole();
175 }
176 void accessibilityActiveChanged(bool active) override
177 {
178 QQuickControl::accessibilityActiveChanged(active);
179 handleAccessibilityActiveChanged(active);
180 }
181#endif
182
183private:
184 Q_DISABLE_COPY(QQuickSpinBox)
185 Q_DECLARE_PRIVATE(QQuickSpinBox)
186 friend class QQuickAbstractSpinBox<QQuickSpinBox, int>;
187 QQuickControlPrivate *d_base_func();
188 const QQuickControlPrivate *d_base_func() const;
189};
190
191QT_END_NAMESPACE
192
193#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.