qspinbox.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets 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 The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QSPINBOX_H
  40. #define QSPINBOX_H
  41. #include <QtWidgets/qabstractspinbox.h>
  42. QT_BEGIN_NAMESPACE
  43. #ifndef QT_NO_SPINBOX
  44. class QSpinBoxPrivate;
  45. class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox
  46. {
  47. Q_OBJECT
  48. Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
  49. Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
  50. Q_PROPERTY(QString cleanText READ cleanText)
  51. Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
  52. Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
  53. Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
  54. Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
  55. Q_PROPERTY(int displayIntegerBase READ displayIntegerBase WRITE setDisplayIntegerBase)
  56. public:
  57. explicit QSpinBox(QWidget *parent = Q_NULLPTR);
  58. ~QSpinBox();
  59. int value() const;
  60. QString prefix() const;
  61. void setPrefix(const QString &prefix);
  62. QString suffix() const;
  63. void setSuffix(const QString &suffix);
  64. QString cleanText() const;
  65. int singleStep() const;
  66. void setSingleStep(int val);
  67. int minimum() const;
  68. void setMinimum(int min);
  69. int maximum() const;
  70. void setMaximum(int max);
  71. void setRange(int min, int max);
  72. int displayIntegerBase() const;
  73. void setDisplayIntegerBase(int base);
  74. protected:
  75. bool event(QEvent *event);
  76. virtual QValidator::State validate(QString &input, int &pos) const;
  77. virtual int valueFromText(const QString &text) const;
  78. virtual QString textFromValue(int val) const;
  79. virtual void fixup(QString &str) const;
  80. public Q_SLOTS:
  81. void setValue(int val);
  82. Q_SIGNALS:
  83. void valueChanged(int);
  84. void valueChanged(const QString &);
  85. private:
  86. Q_DISABLE_COPY(QSpinBox)
  87. Q_DECLARE_PRIVATE(QSpinBox)
  88. };
  89. class QDoubleSpinBoxPrivate;
  90. class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox
  91. {
  92. Q_OBJECT
  93. Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
  94. Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
  95. Q_PROPERTY(QString cleanText READ cleanText)
  96. Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
  97. Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
  98. Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
  99. Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
  100. Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
  101. public:
  102. explicit QDoubleSpinBox(QWidget *parent = Q_NULLPTR);
  103. ~QDoubleSpinBox();
  104. double value() const;
  105. QString prefix() const;
  106. void setPrefix(const QString &prefix);
  107. QString suffix() const;
  108. void setSuffix(const QString &suffix);
  109. QString cleanText() const;
  110. double singleStep() const;
  111. void setSingleStep(double val);
  112. double minimum() const;
  113. void setMinimum(double min);
  114. double maximum() const;
  115. void setMaximum(double max);
  116. void setRange(double min, double max);
  117. int decimals() const;
  118. void setDecimals(int prec);
  119. virtual QValidator::State validate(QString &input, int &pos) const;
  120. virtual double valueFromText(const QString &text) const;
  121. virtual QString textFromValue(double val) const;
  122. virtual void fixup(QString &str) const;
  123. public Q_SLOTS:
  124. void setValue(double val);
  125. Q_SIGNALS:
  126. void valueChanged(double);
  127. void valueChanged(const QString &);
  128. private:
  129. Q_DISABLE_COPY(QDoubleSpinBox)
  130. Q_DECLARE_PRIVATE(QDoubleSpinBox)
  131. };
  132. #endif // QT_NO_SPINBOX
  133. QT_END_NAMESPACE
  134. #endif // QSPINBOX_H