1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
442 Q_D(QSpinBox); |
446 Q_D(QSpinBox); |
443 d->setRange(QVariant(minimum), QVariant(maximum)); |
447 d->setRange(QVariant(minimum), QVariant(maximum)); |
444 } |
448 } |
445 |
449 |
446 /*! |
450 /*! |
447 This virtual function is used by the spin box whenever it needs |
451 This virtual function is used by the spin box whenever it needs to |
448 to display the given \a value. The default implementation returns |
452 display the given \a value. The default implementation returns a |
449 a string containing \a value printed in the standard way using |
453 string containing \a value printed in the standard way using |
450 QWidget::locale().toString(). Reimplementations may return anything. (See |
454 QWidget::locale().toString(), but with the thousand separator |
451 the example in the detailed description.) |
455 removed. Reimplementations may return anything. (See the example |
|
456 in the detailed description.) |
452 |
457 |
453 Note: QSpinBox does not call this function for specialValueText() |
458 Note: QSpinBox does not call this function for specialValueText() |
454 and that neither prefix() nor suffix() should be included in the |
459 and that neither prefix() nor suffix() should be included in the |
455 return value. |
460 return value. |
456 |
461 |
457 If you reimplement this, you may also need to reimplement |
462 If you reimplement this, you may also need to reimplement |
458 valueFromText() and validate() |
463 valueFromText() and validate() |
459 |
464 |
460 \sa valueFromText(), validate() |
465 \sa valueFromText(), validate(), QLocale::groupSeparator() |
461 */ |
466 */ |
462 |
467 |
463 QString QSpinBox::textFromValue(int value) const |
468 QString QSpinBox::textFromValue(int value) const |
464 { |
469 { |
465 QString str = locale().toString(value); |
470 QString str = locale().toString(value); |
811 */ |
818 */ |
812 |
819 |
813 void QDoubleSpinBox::setRange(double minimum, double maximum) |
820 void QDoubleSpinBox::setRange(double minimum, double maximum) |
814 { |
821 { |
815 Q_D(QDoubleSpinBox); |
822 Q_D(QDoubleSpinBox); |
|
823 d->actualMin = minimum; |
|
824 d->actualMax = maximum; |
816 d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum))); |
825 d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum))); |
817 } |
826 } |
818 |
827 |
819 /*! |
828 /*! |
820 \property QDoubleSpinBox::decimals |
829 \property QDoubleSpinBox::decimals |
841 void QDoubleSpinBox::setDecimals(int decimals) |
850 void QDoubleSpinBox::setDecimals(int decimals) |
842 { |
851 { |
843 Q_D(QDoubleSpinBox); |
852 Q_D(QDoubleSpinBox); |
844 d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG); |
853 d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG); |
845 |
854 |
846 setRange(minimum(), maximum()); // make sure values are rounded |
855 setRange(d->actualMin, d->actualMax); // make sure values are rounded |
847 setValue(value()); |
856 setValue(value()); |
848 } |
857 } |
849 |
858 |
850 /*! |
859 /*! |
851 This virtual function is used by the spin box whenever it needs to |
860 This virtual function is used by the spin box whenever it needs to |
1049 Constructs a QSpinBoxPrivate object |
1058 Constructs a QSpinBoxPrivate object |
1050 */ |
1059 */ |
1051 |
1060 |
1052 QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() |
1061 QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() |
1053 { |
1062 { |
1054 minimum = QVariant(0.0); |
1063 actualMin = 0.0; |
1055 maximum = QVariant(99.99); |
1064 actualMax = 99.99; |
|
1065 minimum = QVariant(actualMin); |
|
1066 maximum = QVariant(actualMax); |
1056 value = minimum; |
1067 value = minimum; |
1057 singleStep = QVariant(1.0); |
1068 singleStep = QVariant(1.0); |
1058 decimals = 2; |
1069 decimals = 2; |
1059 type = QVariant::Double; |
1070 type = QVariant::Double; |
1060 } |
1071 } |