1// Copyright (C) 2016 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
4#ifndef QSPINBOX_H
5#define QSPINBOX_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qabstractspinbox.h>
9
10QT_REQUIRE_CONFIG(spinbox);
11
12QT_BEGIN_NAMESPACE
13
14class QSpinBoxPrivate;
15class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox
16{
17 Q_OBJECT
18
19 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
20 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
21 Q_PROPERTY(QString cleanText READ cleanText)
22 Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
23 Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
24 Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
25 Q_PROPERTY(StepType stepType READ stepType WRITE setStepType)
26 Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
27 Q_PROPERTY(int displayIntegerBase READ displayIntegerBase WRITE setDisplayIntegerBase)
28
29public:
30 explicit QSpinBox(QWidget *parent = nullptr);
31 ~QSpinBox();
32
33 int value() const;
34
35 QString prefix() const;
36 void setPrefix(const QString &prefix);
37
38 QString suffix() const;
39 void setSuffix(const QString &suffix);
40
41 QString cleanText() const;
42
43 int singleStep() const;
44 void setSingleStep(int val);
45
46 int minimum() const;
47 void setMinimum(int min);
48
49 int maximum() const;
50 void setMaximum(int max);
51
52 void setRange(int min, int max);
53
54 StepType stepType() const;
55 void setStepType(StepType stepType);
56
57 int displayIntegerBase() const;
58 void setDisplayIntegerBase(int base);
59
60protected:
61 bool event(QEvent *event) override;
62 QValidator::State validate(QString &input, int &pos) const override;
63 virtual int valueFromText(const QString &text) const;
64 virtual QString textFromValue(int val) const;
65 void fixup(QString &str) const override;
66
67
68public Q_SLOTS:
69 void setValue(int val);
70
71Q_SIGNALS:
72 void valueChanged(int);
73 void textChanged(const QString &);
74
75private:
76 Q_DISABLE_COPY(QSpinBox)
77 Q_DECLARE_PRIVATE(QSpinBox)
78};
79
80class QDoubleSpinBoxPrivate;
81class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox
82{
83 Q_OBJECT
84
85 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
86 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
87 Q_PROPERTY(QString cleanText READ cleanText)
88 Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
89 Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
90 Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
91 Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
92 Q_PROPERTY(StepType stepType READ stepType WRITE setStepType)
93 Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
94public:
95 explicit QDoubleSpinBox(QWidget *parent = nullptr);
96 ~QDoubleSpinBox();
97
98 double value() const;
99
100 QString prefix() const;
101 void setPrefix(const QString &prefix);
102
103 QString suffix() const;
104 void setSuffix(const QString &suffix);
105
106 QString cleanText() const;
107
108 double singleStep() const;
109 void setSingleStep(double val);
110
111 double minimum() const;
112 void setMinimum(double min);
113
114 double maximum() const;
115 void setMaximum(double max);
116
117 void setRange(double min, double max);
118
119 StepType stepType() const;
120 void setStepType(StepType stepType);
121
122 int decimals() const;
123 void setDecimals(int prec);
124
125 QValidator::State validate(QString &input, int &pos) const override;
126 virtual double valueFromText(const QString &text) const;
127 virtual QString textFromValue(double val) const;
128 void fixup(QString &str) const override;
129
130public Q_SLOTS:
131 void setValue(double val);
132
133Q_SIGNALS:
134 void valueChanged(double);
135 void textChanged(const QString &);
136
137private:
138 Q_DISABLE_COPY(QDoubleSpinBox)
139 Q_DECLARE_PRIVATE(QDoubleSpinBox)
140};
141
142QT_END_NAMESPACE
143
144#endif // QSPINBOX_H
145

source code of qtbase/src/widgets/widgets/qspinbox.h