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
qquickdoublespinbox_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QQUICKDOUBLESPINBOX_P_H
6#define QQUICKDOUBLESPINBOX_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 QQuickDoubleSpinBox
30 : public QQuickControl,
31 public QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>
32{
33 Q_OBJECT
34 Q_PROPERTY(double from READ from WRITE setFrom NOTIFY fromChanged FINAL)
35 Q_PROPERTY(double to READ to WRITE setTo NOTIFY toChanged FINAL)
36 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged FINAL)
37 Q_PROPERTY(double stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
38 Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged FINAL)
39 Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL)
40
41#if QT_CONFIG(validator)
42 Q_PROPERTY(QValidator *validator READ validator WRITE setValidator
43 NOTIFY validatorChanged FINAL)
44#endif
45 Q_PROPERTY(QJSValue textFromValue READ textFromValue WRITE setTextFromValue
46 NOTIFY textFromValueChanged FINAL)
47 Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText
48 NOTIFY valueFromTextChanged FINAL)
49 Q_PROPERTY(QQuickIndicatorButton *up READ up CONSTANT FINAL)
50 Q_PROPERTY(QQuickIndicatorButton *down READ down CONSTANT FINAL)
51 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints
52 NOTIFY inputMethodHintsChanged FINAL)
53 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing
54 NOTIFY inputMethodComposingChanged FINAL)
55 Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL)
56 Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged FINAL)
57 QML_NAMED_ELEMENT(DoubleSpinBox)
58 QML_ADDED_IN_VERSION(6, 11)
59
60public:
61 explicit QQuickDoubleSpinBox(QQuickItem *parent = nullptr);
62 ~QQuickDoubleSpinBox();
63
64 void setFrom(double from);
65
66 void setTo(double to);
67
68 void setValue(double value);
69
70 void setStepSize(double step);
71
72 int decimals() const;
73 void setDecimals(int prec);
74
75 QJSValue textFromValue() const;
76
77 QJSValue valueFromText() const;
78
79 void setWrap(bool wrap);
80
81public Q_SLOTS:
82 void increase() override;
83 void decrease() override;
85Q_SIGNALS:
86 void fromChanged();
87 void toChanged();
88 void valueChanged();
89 void stepSizeChanged();
90 void decimalsChanged();
91 void editableChanged();
92#if QT_CONFIG(validator)
93 void validatorChanged();
94#endif
95 void textFromValueChanged();
96 void valueFromTextChanged();
97 void valueModified();
98 void inputMethodHintsChanged();
99 void inputMethodComposingChanged();
100 void wrapChanged();
101 void displayTextChanged();
102
103protected:
104 void focusInEvent(QFocusEvent *event) override
106 QQuickControl::focusInEvent(event);
107 handleFocusInEvent(event);
108 }
109 void hoverEnterEvent(QHoverEvent *event) override
111 QQuickControl::hoverEnterEvent(event);
112 handleHoverEnterEvent(event);
113 }
114 void hoverMoveEvent(QHoverEvent *event) override
116 QQuickControl::hoverMoveEvent(event);
117 handleHoverMoveEvent(event);
118 }
119 void hoverLeaveEvent(QHoverEvent *event) override
121 QQuickControl::hoverLeaveEvent(event);
122 handleHoverLeaveEvent(event);
123 }
124 void keyPressEvent(QKeyEvent *event) override
126 QQuickControl::keyPressEvent(event);
127 handleKeyPressEvent(event);
128 }
129 void keyReleaseEvent(QKeyEvent *event) override
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
148 QQuickControl::classBegin();
149 handleClassBegin();
150 }
151 void componentComplete() override
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
164 QQuickControl::localeChange(newLocale, oldLocale);
165 handleLocaleChange();
166 }
167 QFont defaultFont() const override
168 {
169 return QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>::defaultFont();
170 }
171#if QT_CONFIG(accessibility)
172 QAccessible::Role accessibleRole() const override
173 {
174 return QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>::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(QQuickDoubleSpinBox)
185 Q_DECLARE_PRIVATE(QQuickDoubleSpinBox)
186 friend class QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>;
187 QQuickControlPrivate *d_base_func();
188 const QQuickControlPrivate *d_base_func() const;
189};
190
191QT_END_NAMESPACE
192
193#endif // QQUICKDOUBLESPINBOX_P_H
Allows the user to select from a set of preset floating-point values.
bool setValue(double newValue, bool wrap, ValueStatus modified) override
QString evaluateTextFromValue(double val, int decimals) const
double evaluateValueFromText(const QString &text) const
double round(double input) const
Combined button and popup list for selecting options.