Qt 4.8
qspinbox.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QSPINBOX_H
43 #define QSPINBOX_H
44 
45 #include <QtGui/qabstractspinbox.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_SPINBOX
54 
55 class QSpinBoxPrivate;
57 {
58  Q_OBJECT
59 
63  int minimum;
64  int maximum;
66  int value;
67 
68 public:
69  explicit QSpinBox(QWidget *parent = 0);
70 #ifdef QT3_SUPPORT
71  QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name);
72  QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent,
73  const char *name = 0);
74 #endif
75 
76  int value() const;
77 
78  QString prefix() const;
79  void setPrefix(const QString &prefix);
80 
81  QString suffix() const;
82  void setSuffix(const QString &suffix);
83 
84  QString cleanText() const;
85 
86  int singleStep() const;
87  void setSingleStep(int val);
88 
89  int minimum() const;
90  void setMinimum(int min);
91 
92  int maximum() const;
93  void setMaximum(int max);
94 
95  void setRange(int min, int max);
96 
97 #ifdef QT3_SUPPORT
98  inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); }
99  inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); }
100  inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); }
101  inline QT3_SUPPORT int maxValue() const { return maximum(); }
102  inline QT3_SUPPORT int minValue() const { return minimum(); }
103 #endif
104 
105 protected:
106  bool event(QEvent *event);
107  virtual QValidator::State validate(QString &input, int &pos) const;
108  virtual int valueFromText(const QString &text) const;
109  virtual QString textFromValue(int val) const;
110  virtual void fixup(QString &str) const;
111 
112 
113 public Q_SLOTS:
114  void setValue(int val);
115 
116 Q_SIGNALS:
117  void valueChanged(int);
118  void valueChanged(const QString &);
119 
120 private:
123 };
124 
127 {
128  Q_OBJECT
129 
133  int decimals;
134  double minimum;
135  double maximum;
136  double singleStep;
137  double value;
138 public:
139  explicit QDoubleSpinBox(QWidget *parent = 0);
140 
141  double value() const;
142 
143  QString prefix() const;
144  void setPrefix(const QString &prefix);
145 
146  QString suffix() const;
147  void setSuffix(const QString &suffix);
148 
149  QString cleanText() const;
150 
151  double singleStep() const;
152  void setSingleStep(double val);
153 
154  double minimum() const;
155  void setMinimum(double min);
156 
157  double maximum() const;
158  void setMaximum(double max);
159 
160  void setRange(double min, double max);
161 
162  int decimals() const;
163  void setDecimals(int prec);
164 
165  virtual QValidator::State validate(QString &input, int &pos) const;
166  virtual double valueFromText(const QString &text) const;
167  virtual QString textFromValue(double val) const;
168  virtual void fixup(QString &str) const;
169 
170 public Q_SLOTS:
171  void setValue(double val);
172 
173 Q_SIGNALS:
174  void valueChanged(double);
175  void valueChanged(const QString &);
176 
177 private:
180 };
181 
182 #endif // QT_NO_SPINBOX
183 
185 
187 
188 #endif // QSPINBOX_H
virtual void fixup(QString &input) const
This virtual function is called by the QAbstractSpinBox if the input is not validated to QValidator::...
QString suffix
the suffix of the spin box
Definition: qspinbox.h:60
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QString prefix
the spin box&#39;s prefix
Definition: qspinbox.h:61
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
Definition: qspinbox.h:132
int singleStep
the step value
Definition: qspinbox.h:65
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_SIGNALS
Definition: qobjectdefs.h:72
double value
the value of the spin box
Definition: qspinbox.h:137
double minimum
the minimum value of the spin box
Definition: qspinbox.h:134
int decimals
the precision of the spin box, in decimals
Definition: qspinbox.h:133
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
double maximum
the maximum value of the spin box
Definition: qspinbox.h:135
const char * name
int maximum
the maximum value of the spin box
Definition: qspinbox.h:64
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual QValidator::State validate(QString &input, int &pos) const
This virtual function is called by the QAbstractSpinBox to determine whether input is valid...
int value
the value of the spin box
Definition: qspinbox.h:66
QString prefix
the spin box&#39;s prefix
Definition: qspinbox.h:130
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126
QByteArray suffix
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
The QSpinBox class provides a spin box widget.
Definition: qspinbox.h:56
QString suffix
the suffix of the spin box
Definition: qspinbox.h:131
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool event(QEvent *event)
Reimplemented Function
int minimum
the minimum value of the spin box
Definition: qspinbox.h:63
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
QString cleanText
the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.
Definition: qspinbox.h:62
#define text
Definition: qobjectdefs.h:80
double singleStep
the step value
Definition: qspinbox.h:136