Qt 4.8
qspinbox.cpp
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 #include <private/qabstractspinbox_p.h>
43 #include <qspinbox.h>
44 
45 #ifndef QT_NO_SPINBOX
46 
47 #include <qlineedit.h>
48 #include <qlocale.h>
49 #include <qvalidator.h>
50 #include <qdebug.h>
51 
52 #include <math.h>
53 #include <float.h>
54 
56 
57 //#define QSPINBOX_QSBDEBUG
58 #ifdef QSPINBOX_QSBDEBUG
59 # define QSBDEBUG qDebug
60 #else
61 # define QSBDEBUG if (false) qDebug
62 #endif
63 
65 {
67 public:
69  void emitSignals(EmitPolicy ep, const QVariant &);
70 
71  virtual QVariant valueFromText(const QString &n) const;
72  virtual QString textFromValue(const QVariant &n) const;
73  QVariant validateAndInterpret(QString &input, int &pos,
74  QValidator::State &state) const;
75 
76  inline void init() {
77  Q_Q(QSpinBox);
78  q->setInputMethodHints(Qt::ImhDigitsOnly);
80  }
81 };
82 
84 {
86 public:
88  void emitSignals(EmitPolicy ep, const QVariant &);
89 
90  virtual QVariant valueFromText(const QString &n) const;
91  virtual QString textFromValue(const QVariant &n) const;
92  QVariant validateAndInterpret(QString &input, int &pos,
93  QValidator::State &state) const;
94  double round(double input) const;
95  // variables
96  int decimals;
97 
98  inline void init() {
100  q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
101  }
102 
103  // When fiddling with the decimals property, we may lose precision in these properties.
104  double actualMin;
105  double actualMax;
106 };
107 
108 
215  : QAbstractSpinBox(*new QSpinBoxPrivate, parent)
216 {
217  Q_D(QSpinBox);
218  d->init();
219 }
220 
221 #ifdef QT3_SUPPORT
222 
226 QSpinBox::QSpinBox(QWidget *parent, const char *name)
227  : QAbstractSpinBox(*new QSpinBoxPrivate, parent)
228 {
229  Q_D(QSpinBox);
231  d->init();
232 }
233 
238 QSpinBox::QSpinBox(int minimum, int maximum, int step, QWidget *parent, const char *name)
239  : QAbstractSpinBox(*new QSpinBoxPrivate, parent)
240 {
241  Q_D(QSpinBox);
242  d->minimum = QVariant(qMin<int>(minimum, maximum));
243  d->maximum = QVariant(qMax<int>(minimum, maximum));
244  d->singleStep = QVariant(step);
246  d->init();
247 }
248 
249 #endif
250 
262 int QSpinBox::value() const
263 {
264  Q_D(const QSpinBox);
265  return d->value.toInt();
266 }
267 
269 {
270  Q_D(QSpinBox);
271  d->setValue(QVariant(value), EmitIfChanged);
272 }
273 
297 {
298  Q_D(const QSpinBox);
299  return d->prefix;
300 }
301 
303 {
304  Q_D(QSpinBox);
305 
306  d->prefix = prefix;
307  d->updateEdit();
308 
309  d->cachedSizeHint = QSize();
310  updateGeometry();
311 }
312 
336 {
337  Q_D(const QSpinBox);
338 
339  return d->suffix;
340 }
341 
343 {
344  Q_D(QSpinBox);
345 
346  d->suffix = suffix;
347  d->updateEdit();
348 
349  d->cachedSizeHint = QSize();
350  updateGeometry();
351 }
352 
366 {
367  Q_D(const QSpinBox);
368 
369  return d->stripped(d->edit->displayText());
370 }
371 
372 
386 int QSpinBox::singleStep() const
387 {
388  Q_D(const QSpinBox);
389 
390  return d->singleStep.toInt();
391 }
392 
394 {
395  Q_D(QSpinBox);
396  if (value >= 0) {
397  d->singleStep = QVariant(value);
398  d->updateEdit();
399  }
400 }
401 
418 int QSpinBox::minimum() const
419 {
420  Q_D(const QSpinBox);
421 
422  return d->minimum.toInt();
423 }
424 
426 {
427  Q_D(QSpinBox);
428  const QVariant m(minimum);
429  d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m));
430 }
431 
449 int QSpinBox::maximum() const
450 {
451  Q_D(const QSpinBox);
452 
453  return d->maximum.toInt();
454 }
455 
457 {
458  Q_D(QSpinBox);
459  const QVariant m(maximum);
460  d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);
461 }
462 
475 {
476  Q_D(QSpinBox);
477  d->setRange(QVariant(minimum), QVariant(maximum));
478 }
479 
499 {
500  QString str = locale().toString(value);
501  if (qAbs(value) >= 1000 || value == INT_MIN) {
502  str.remove(locale().groupSeparator());
503  }
504 
505  return str;
506 }
507 
527 {
528  Q_D(const QSpinBox);
529 
530  QString copy = text;
531  int pos = d->edit->cursorPosition();
533  return d->validateAndInterpret(copy, pos, state).toInt();
534 }
535 
540 {
541  Q_D(const QSpinBox);
542 
543  QValidator::State state;
544  d->validateAndInterpret(text, pos, state);
545  return state;
546 }
547 
548 
552 void QSpinBox::fixup(QString &input) const
553 {
554  input.remove(locale().groupSeparator());
555 }
556 
557 
558 // --- QDoubleSpinBox ---
559 
646 {
648  d->init();
649 }
650 
666 double QDoubleSpinBox::value() const
667 {
668  Q_D(const QDoubleSpinBox);
669 
670  return d->value.toDouble();
671 }
672 
674 {
676  QVariant v(d->round(value));
677  d->setValue(v, EmitIfChanged);
678 }
702 {
703  Q_D(const QDoubleSpinBox);
704 
705  return d->prefix;
706 }
707 
709 {
711 
712  d->prefix = prefix;
713  d->updateEdit();
714 }
715 
739 {
740  Q_D(const QDoubleSpinBox);
741 
742  return d->suffix;
743 }
744 
746 {
748 
749  d->suffix = suffix;
750  d->updateEdit();
751 
752  d->cachedSizeHint = QSize();
753  updateGeometry();
754 }
755 
769 {
770  Q_D(const QDoubleSpinBox);
771 
772  return d->stripped(d->edit->displayText());
773 }
774 
787 double QDoubleSpinBox::singleStep() const
788 {
789  Q_D(const QDoubleSpinBox);
790 
791  return d->singleStep.toDouble();
792 }
793 
795 {
797 
798  if (value >= 0) {
799  d->singleStep = value;
800  d->updateEdit();
801  }
802 }
803 
823 double QDoubleSpinBox::minimum() const
824 {
825  Q_D(const QDoubleSpinBox);
826 
827  return d->minimum.toDouble();
828 }
829 
831 {
833  d->actualMin = minimum;
834  const QVariant m(d->round(minimum));
835  d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m));
836 }
837 
857 double QDoubleSpinBox::maximum() const
858 {
859  Q_D(const QDoubleSpinBox);
860 
861  return d->maximum.toDouble();
862 }
863 
865 {
867  d->actualMax = maximum;
868  const QVariant m(d->round(maximum));
869  d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);
870 }
871 
887 {
889  d->actualMin = minimum;
890  d->actualMax = maximum;
891  d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum)));
892 }
893 
912 int QDoubleSpinBox::decimals() const
913 {
914  Q_D(const QDoubleSpinBox);
915 
916  return d->decimals;
917 }
918 
920 {
922  d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG);
923 
924  setRange(d->actualMin, d->actualMax); // make sure values are rounded
925  setValue(value());
926 }
927 
947 {
948  Q_D(const QDoubleSpinBox);
949  QString str = locale().toString(value, 'f', d->decimals);
950  if (qAbs(value) >= 1000.0) {
951  str.remove(locale().groupSeparator());
952  }
953  return str;
954 }
955 
969 {
970  Q_D(const QDoubleSpinBox);
971 
972  QString copy = text;
973  int pos = d->edit->cursorPosition();
975  return d->validateAndInterpret(copy, pos, state).toDouble();
976 }
977 
982 {
983  Q_D(const QDoubleSpinBox);
984 
985  QValidator::State state;
986  d->validateAndInterpret(text, pos, state);
987  return state;
988 }
989 
990 
994 void QDoubleSpinBox::fixup(QString &input) const
995 {
996  input.remove(locale().groupSeparator());
997 }
998 
999 // --- QSpinBoxPrivate ---
1000 
1007 {
1008  minimum = QVariant((int)0);
1009  maximum = QVariant((int)99);
1010  value = minimum;
1011  singleStep = QVariant((int)1);
1012  type = QVariant::Int;
1013 }
1014 
1021 {
1022  Q_Q(QSpinBox);
1023  if (ep != NeverEmit) {
1024  pendingEmit = false;
1025  if (ep == AlwaysEmit || value != old) {
1026  emit q->valueChanged(edit->displayText());
1027  emit q->valueChanged(value.toInt());
1028  }
1029  }
1030 }
1031 
1038 {
1039  Q_Q(const QSpinBox);
1040  return q->textFromValue(value.toInt());
1041 }
1048 {
1049  Q_Q(const QSpinBox);
1050 
1051  return QVariant(q->valueFromText(text));
1052 }
1053 
1054 
1062  QValidator::State &state) const
1063 {
1064  if (cachedText == input && !input.isEmpty()) {
1065  state = cachedState;
1066  QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
1067  << state << " and value was " << cachedValue;
1068 
1069  return cachedValue;
1070  }
1071  const int max = maximum.toInt();
1072  const int min = minimum.toInt();
1073 
1074  QString copy = stripped(input, &pos);
1075  QSBDEBUG() << "input" << input << "copy" << copy;
1076  state = QValidator::Acceptable;
1077  int num = min;
1078 
1079  if (max != min && (copy.isEmpty()
1080  || (min < 0 && copy == QLatin1String("-"))
1081  || (min >= 0 && copy == QLatin1String("+")))) {
1082  state = QValidator::Intermediate;
1083  QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
1084  } else if (copy.startsWith(QLatin1Char('-')) && min >= 0) {
1085  state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100
1086  } else {
1087  bool ok = false;
1088  num = locale.toInt(copy, &ok, 10);
1089  if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) {
1090  QString copy2 = copy;
1091  copy2.remove(locale.groupSeparator());
1092  num = locale.toInt(copy2, &ok, 10);
1093  }
1094  QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
1095  if (!ok) {
1096  state = QValidator::Invalid;
1097  } else if (num >= min && num <= max) {
1098  state = QValidator::Acceptable;
1099  } else if (max == min) {
1100  state = QValidator::Invalid;
1101  } else {
1102  if ((num >= 0 && num > max) || (num < 0 && num < min)) {
1103  state = QValidator::Invalid;
1104  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1105  } else {
1106  state = QValidator::Intermediate;
1107  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate";
1108  }
1109  }
1110  }
1111  if (state != QValidator::Acceptable)
1112  num = max > 0 ? min : max;
1113  input = prefix + copy + suffix;
1114  cachedText = input;
1115  cachedState = state;
1116  cachedValue = QVariant((int)num);
1117 
1118  QSBDEBUG() << "cachedText is set to '" << cachedText << "' state is set to "
1119  << state << " and value is set to " << cachedValue;
1120  return cachedValue;
1121 }
1122 
1123 // --- QDoubleSpinBoxPrivate ---
1124 
1131 {
1132  actualMin = 0.0;
1133  actualMax = 99.99;
1134  minimum = QVariant(actualMin);
1135  maximum = QVariant(actualMax);
1136  value = minimum;
1137  singleStep = QVariant(1.0);
1138  decimals = 2;
1140 }
1141 
1148 {
1150  if (ep != NeverEmit) {
1151  pendingEmit = false;
1152  if (ep == AlwaysEmit || value != old) {
1153  emit q->valueChanged(edit->displayText());
1154  emit q->valueChanged(value.toDouble());
1155  }
1156  }
1157 }
1158 
1159 
1165 {
1166  Q_Q(const QDoubleSpinBox);
1167  return QVariant(q->valueFromText(f));
1168 }
1169 
1182 {
1183  return QString::number(value, 'f', decimals).toDouble();
1184 }
1185 
1186 
1194  QValidator::State &state) const
1195 {
1196  if (cachedText == input && !input.isEmpty()) {
1197  state = cachedState;
1198  QSBDEBUG() << "cachedText was '" << cachedText << "' state was "
1199  << state << " and value was " << cachedValue;
1200  return cachedValue;
1201  }
1202  const double max = maximum.toDouble();
1203  const double min = minimum.toDouble();
1204 
1205  QString copy = stripped(input, &pos);
1206  QSBDEBUG() << "input" << input << "copy" << copy;
1207  int len = copy.size();
1208  double num = min;
1209  const bool plus = max >= 0;
1210  const bool minus = min <= 0;
1211 
1212  switch (len) {
1213  case 0:
1214  state = max != min ? QValidator::Intermediate : QValidator::Invalid;
1215  goto end;
1216  case 1:
1217  if (copy.at(0) == locale.decimalPoint()
1218  || (plus && copy.at(0) == QLatin1Char('+'))
1219  || (minus && copy.at(0) == QLatin1Char('-'))) {
1220  state = QValidator::Intermediate;
1221  goto end;
1222  }
1223  break;
1224  case 2:
1225  if (copy.at(1) == locale.decimalPoint()
1226  && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) {
1227  state = QValidator::Intermediate;
1228  goto end;
1229  }
1230  break;
1231  default: break;
1232  }
1233 
1234  if (copy.at(0) == locale.groupSeparator()) {
1235  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1236  state = QValidator::Invalid;
1237  goto end;
1238  } else if (len > 1) {
1239  const int dec = copy.indexOf(locale.decimalPoint());
1240  if (dec != -1) {
1241  if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) {
1242  copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter
1243  } // should be treated as typing right arrow
1244 
1245  if (copy.size() - dec > decimals + 1) {
1246  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1247  state = QValidator::Invalid;
1248  goto end;
1249  }
1250  for (int i=dec + 1; i<copy.size(); ++i) {
1251  if (copy.at(i).isSpace() || copy.at(i) == locale.groupSeparator()) {
1252  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1253  state = QValidator::Invalid;
1254  goto end;
1255  }
1256  }
1257  } else {
1258  const QChar &last = copy.at(len - 1);
1259  const QChar &secondLast = copy.at(len - 2);
1260  if ((last == locale.groupSeparator() || last.isSpace())
1261  && (secondLast == locale.groupSeparator() || secondLast.isSpace())) {
1262  state = QValidator::Invalid;
1263  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1264  goto end;
1265  } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) {
1266  state = QValidator::Invalid;
1267  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1268  goto end;
1269  }
1270  }
1271  }
1272 
1273  {
1274  bool ok = false;
1275  num = locale.toDouble(copy, &ok);
1276  QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok;
1277 
1278  if (!ok) {
1279  if (locale.groupSeparator().isPrint()) {
1280  if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) {
1281  state = QValidator::Invalid;
1282  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1283  goto end;
1284  }
1285 
1286  const int len = copy.size();
1287  for (int i=0; i<len- 1; ++i) {
1288  if (copy.at(i) == locale.groupSeparator() && copy.at(i + 1) == locale.groupSeparator()) {
1289  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1290  state = QValidator::Invalid;
1291  goto end;
1292  }
1293  }
1294 
1295  QString copy2 = copy;
1296  copy2.remove(locale.groupSeparator());
1297  num = locale.toDouble(copy2, &ok);
1298  QSBDEBUG() << locale.groupSeparator() << num << copy2 << ok;
1299 
1300  if (!ok) {
1301  state = QValidator::Invalid;
1302  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1303  goto end;
1304  }
1305  }
1306  }
1307 
1308  if (!ok) {
1309  state = QValidator::Invalid;
1310  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1311  } else if (num >= min && num <= max) {
1312  state = QValidator::Acceptable;
1313  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable";
1314  } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
1315  state = QValidator::Invalid;
1316  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1317  } else {
1318  if ((num >= 0 && num > max) || (num < 0 && num < min)) {
1319  state = QValidator::Invalid;
1320  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid";
1321  } else {
1322  state = QValidator::Intermediate;
1323  QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Intermediate";
1324  }
1325  }
1326  }
1327 
1328 end:
1329  if (state != QValidator::Acceptable) {
1330  num = max > 0 ? min : max;
1331  }
1332 
1333  input = prefix + copy + suffix;
1334  cachedText = input;
1335  cachedState = state;
1336  cachedValue = QVariant(num);
1337  return QVariant(num);
1338 }
1339 
1340 /*
1341  \internal
1342  \reimp
1343 */
1344 
1346 {
1347  Q_Q(const QDoubleSpinBox);
1348  return q->textFromValue(f.toDouble());
1349 }
1350 
1398 {
1399  Q_D(QSpinBox);
1400  if (event->type() == QEvent::StyleChange
1401 #ifdef Q_WS_MAC
1402  || event->type() == QEvent::MacSizeChange
1403 #endif
1404  )
1405  d->setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
1406  return QAbstractSpinBox::event(event);
1407 }
1408 
1410 
1411 #endif // QT_NO_SPINBOX
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void emitSignals(EmitPolicy ep, const QVariant &)
Definition: qspinbox.cpp:1147
QPoint pos() const
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
QSpinBox(QWidget *parent=0)
Constructs a spin box with 0 as minimum value and 99 as maximum value, a step value of 1...
Definition: qspinbox.cpp:214
void setValue(double val)
Definition: qspinbox.cpp:673
bool event(QEvent *event)
Reimplemented Function
Definition: qspinbox.cpp:1397
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLocale locale() const
QString cleanText() const
void setRange(double min, double max)
Convenience function to set the minimum and maximum values with a single function call...
Definition: qspinbox.cpp:886
#define DBL_DIG
Definition: qvariant.cpp:69
double round(double input) const
Rounds to a double value that is restricted to decimals.
Definition: qspinbox.cpp:1181
static glyph_t stripped(glyph_t glyph)
int decimals() const
int singleStep() const
EmitPolicy
virtual QValidator::State validate(QString &input, int &pos) const
Reimplemented Function
Definition: qspinbox.cpp:539
virtual QString textFromValue(const QVariant &n) const
Definition: qspinbox.cpp:1037
virtual QString textFromValue(int val) const
This virtual function is used by the spin box whenever it needs to display the given value...
Definition: qspinbox.cpp:498
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QAbstractSpinBox(QWidget *parent=0)
Constructs an abstract spinbox with the given parent with default wrapping , and alignment properties...
virtual void fixup(QString &str) const
Reimplemented Function
Definition: qspinbox.cpp:552
virtual QString textFromValue(const QVariant &n) const
Virtual method called that calls the public textFromValue() functions in the subclasses.
Definition: qspinbox.cpp:1345
QString suffix() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setValue(int val)
Definition: qspinbox.cpp:268
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
Definition: qchar.cpp:598
void setLayoutItemMargins(int left, int top, int right, int bottom)
Definition: qwidget.cpp:12860
#define Q_D(Class)
Definition: qglobal.h:2482
#define QSBDEBUG
Definition: qspinbox.cpp:61
void setPrefix(const QString &prefix)
Definition: qspinbox.cpp:708
void setRange(int min, int max)
Convenience function to set the minimum, and maximum values with a single function call...
Definition: qspinbox.cpp:474
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
void setDecimals(int prec)
Definition: qspinbox.cpp:919
Q_CORE_EXPORT QTextStream & dec(QTextStream &s)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
int value() const
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QString suffix() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QDoubleSpinBox(QWidget *parent=0)
Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, a step value of 1...
Definition: qspinbox.cpp:644
void setSuffix(const QString &suffix)
Definition: qspinbox.cpp:342
QChar decimalPoint() const
Returns the decimal point character of this locale.
Definition: qlocale.cpp:1765
int minimum() const
QChar groupSeparator() const
Returns the group separator character of this locale.
Definition: qlocale.cpp:1778
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual QVariant valueFromText(const QString &n) const
Definition: qspinbox.cpp:1164
void setSingleStep(double val)
Definition: qspinbox.cpp:794
QString cleanText() const
double maximum() const
void setSuffix(const QString &suffix)
Definition: qspinbox.cpp:745
const char * name
#define emit
Definition: qobjectdefs.h:76
void setSingleStep(int val)
Definition: qspinbox.cpp:393
virtual void fixup(QString &str) const
Reimplemented Function
Definition: qspinbox.cpp:994
void emitSignals(EmitPolicy ep, const QVariant &)
Definition: qspinbox.cpp:1020
void setMinimum(double min)
Definition: qspinbox.cpp:830
int maximum() const
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
virtual QString textFromValue(double val) const
This virtual function is used by the spin box whenever it needs to display the given value...
Definition: qspinbox.cpp:946
QString text() const
QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const
Definition: qspinbox.cpp:1193
double minimum() const
QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const
Definition: qspinbox.cpp:1061
virtual QVariant valueFromText(const QString &n) const
Definition: qspinbox.cpp:1047
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QString prefix() const
double toDouble(const QString &s, bool *ok=0) const
Returns the double represented by the localized string s, or 0.0 if the conversion failed...
Definition: qlocale.cpp:1279
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition: qspinbox.h:126
QString prefix() const
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
virtual int valueFromText(const QString &text) const
This virtual function is used by the spin box whenever it needs to interpret text entered by the user...
Definition: qspinbox.cpp:526
void setPrefix(const QString &prefix)
Definition: qspinbox.cpp:302
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227
virtual double valueFromText(const QString &text) const
This virtual function is used by the spin box whenever it needs to interpret text entered by the user...
Definition: qspinbox.cpp:968
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
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QObject * parent
Definition: qobject.h:92
virtual QValidator::State validate(QString &input, int &pos) const
Reimplemented Function
Definition: qspinbox.cpp:981
double value() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool event(QEvent *event)
Reimplemented Function
int toInt(const QString &s, bool *ok=0, int base=0) const
Returns the int represented by the localized string s, using base base.
Definition: qlocale.cpp:1133
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
void setMaximum(double max)
Definition: qspinbox.cpp:864
static const KeyPair *const end
void setMinimum(int min)
Definition: qspinbox.cpp:425
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
double singleStep() const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void setMaximum(int max)
Definition: qspinbox.cpp:456