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;
79 void setWrap(bool wrap);
81Q_SIGNALS:
82 void fromChanged();
83 void toChanged();
84 void valueChanged();
85 void stepSizeChanged();
86 void decimalsChanged();
87 void editableChanged();
88#if QT_CONFIG(validator)
89 void validatorChanged();
90#endif
91 void textFromValueChanged();
92 void valueFromTextChanged();
93 void valueModified();
94 void inputMethodHintsChanged();
95 void inputMethodComposingChanged();
96 void wrapChanged();
97 void displayTextChanged();
98
99protected:
100 void focusInEvent(QFocusEvent *event) override
102 QQuickControl::focusInEvent(event);
103 handleFocusInEvent(event);
104 }
105 void hoverEnterEvent(QHoverEvent *event) override
107 QQuickControl::hoverEnterEvent(event);
108 handleHoverEnterEvent(event);
109 }
110 void hoverMoveEvent(QHoverEvent *event) override
112 QQuickControl::hoverMoveEvent(event);
113 handleHoverMoveEvent(event);
114 }
115 void hoverLeaveEvent(QHoverEvent *event) override
117 QQuickControl::hoverLeaveEvent(event);
118 handleHoverLeaveEvent(event);
119 }
120 void keyPressEvent(QKeyEvent *event) override
122 QQuickControl::keyPressEvent(event);
123 handleKeyPressEvent(event);
124 }
125 void keyReleaseEvent(QKeyEvent *event) override
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
144 QQuickControl::classBegin();
145 handleClassBegin();
146 }
147 void componentComplete() override
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
160 QQuickControl::localeChange(newLocale, oldLocale);
161 handleLocaleChange();
162 }
163 QFont defaultFont() const override
164 {
165 return QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>::defaultFont();
166 }
167#if QT_CONFIG(accessibility)
168 QAccessible::Role accessibleRole() const override
169 {
170 return QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>::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(QQuickDoubleSpinBox)
181 Q_DECLARE_PRIVATE(QQuickDoubleSpinBox)
182 friend class QQuickAbstractSpinBox<QQuickDoubleSpinBox, double>;
183 QQuickControlPrivate *d_base_func();
184 const QQuickControlPrivate *d_base_func() const;
185};
186
187QT_END_NAMESPACE
188
189#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.