- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qspinbox.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QSPINBOX_H
    00043 #define QSPINBOX_H
    00044
    00045 #include <QtGui/qabstractspinbox.h>
    00046
    00047 QT_BEGIN_HEADER
    00048
    00049 QT_BEGIN_NAMESPACE
    00050
    00051 QT_MODULE(Gui)
    00052
    00053 #ifndef QT_NO_SPINBOX
    00054
    00055 class QSpinBoxPrivate;
    00056 class Q_GUI_EXPORT QSpinBox : public QAbstractSpinBox
    00057 {
    00058     Q_OBJECT
    00059
    00060     Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
    00061     Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
    00062     Q_PROPERTY(QString cleanText READ cleanText)
    00063     Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
    00064     Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
    00065     Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
    00066     Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
    00067
    00068 public:
    00069     explicit QSpinBox(QWidget *parent = 0);
    00070 #ifdef QT3_SUPPORT
    00071     QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name);
    00072     QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent,
    00073                                      const char *name = 0);
    00074 #endif
    00075
    00076     int value() const;
    00077
    00078     QString prefix() const;
    00079     void setPrefix(const QString &prefix);
    00080
    00081     QString suffix() const;
    00082     void setSuffix(const QString &suffix);
    00083
    00084     QString cleanText() const;
    00085
    00086     int singleStep() const;
    00087     void setSingleStep(int val);
    00088
    00089     int minimum() const;
    00090     void setMinimum(int min);
    00091
    00092     int maximum() const;
    00093     void setMaximum(int max);
    00094
    00095     void setRange(int min, int max);
    00096
    00097 #ifdef QT3_SUPPORT
    00098     inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); }
    00099     inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); }
    00100     inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); }
    00101     inline QT3_SUPPORT int maxValue() const { return maximum(); }
    00102     inline QT3_SUPPORT int minValue() const { return minimum(); }
    00103 #endif
    00104
    00105 protected:
    00106     bool event(QEvent *event);
    00107     virtual QValidator::State validate(QString &input, int &pos) const;
    00108     virtual int valueFromText(const QString &text) const;
    00109     virtual QString textFromValue(int val) const;
    00110     virtual void fixup(QString &str) const;
    00111
    00112
    00113 public Q_SLOTS:
    00114     void setValue(int val);
    00115
    00116 Q_SIGNALS:
    00117     void valueChanged(int);
    00118     void valueChanged(const QString &);
    00119
    00120 private:
    00121     Q_DISABLE_COPY(QSpinBox)
    00122     Q_DECLARE_PRIVATE(QSpinBox)
    00123 };
    00124
    00125 class QDoubleSpinBoxPrivate;
    00126 class Q_GUI_EXPORT QDoubleSpinBox : public QAbstractSpinBox
    00127 {
    00128     Q_OBJECT
    00129
    00130     Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
    00131     Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
    00132     Q_PROPERTY(QString cleanText READ cleanText)
    00133     Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
    00134     Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
    00135     Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
    00136     Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
    00137     Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
    00138 public:
    00139     explicit QDoubleSpinBox(QWidget *parent = 0);
    00140
    00141     double value() const;
    00142
    00143     QString prefix() const;
    00144     void setPrefix(const QString &prefix);
    00145
    00146     QString suffix() const;
    00147     void setSuffix(const QString &suffix);
    00148
    00149     QString cleanText() const;
    00150
    00151     double singleStep() const;
    00152     void setSingleStep(double val);
    00153
    00154     double minimum() const;
    00155     void setMinimum(double min);
    00156
    00157     double maximum() const;
    00158     void setMaximum(double max);
    00159
    00160     void setRange(double min, double max);
    00161
    00162     int decimals() const;
    00163     void setDecimals(int prec);
    00164
    00165     virtual QValidator::State validate(QString &input, int &pos) const;
    00166     virtual double valueFromText(const QString &text) const;
    00167     virtual QString textFromValue(double val) const;
    00168     virtual void fixup(QString &str) const;
    00169
    00170 public Q_SLOTS:
    00171     void setValue(double val);
    00172
    00173 Q_SIGNALS:
    00174     void valueChanged(double);
    00175     void valueChanged(const QString &);
    00176
    00177 private:
    00178     Q_DISABLE_COPY(QDoubleSpinBox)
    00179     Q_DECLARE_PRIVATE(QDoubleSpinBox)
    00180 };
    00181
    00182 #endif // QT_NO_SPINBOX
    00183
    00184 QT_END_NAMESPACE
    00185
    00186 QT_END_HEADER
    00187
    00188 #endif // QSPINBOX_H