summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-01-13 20:08:26 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-01-13 20:08:26 (GMT)
commit0193617fe21486561ae55403b80419ad1a9105b2 (patch)
treeda00c7b6a8920a586450e10d58b7fcb8b84ce26d /src/gui/widgets
parentcf32ca450a80d0a9d0be36d74320de651b83ad63 (diff)
parentdc5c5104a3f31b03954b33e1c098e17bc4634f27 (diff)
downloadQt-0193617fe21486561ae55403b80419ad1a9105b2.zip
Qt-0193617fe21486561ae55403b80419ad1a9105b2.tar.gz
Qt-0193617fe21486561ae55403b80419ad1a9105b2.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qspinbox.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index f00296c..726426d 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -99,6 +99,10 @@ public:
Q_Q(QDoubleSpinBox);
q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
}
+
+ // When fiddling with the decimals property, we may lose precision in these properties.
+ double actualMin;
+ double actualMax;
};
@@ -762,6 +766,7 @@ double QDoubleSpinBox::minimum() const
void QDoubleSpinBox::setMinimum(double minimum)
{
Q_D(QDoubleSpinBox);
+ d->actualMin = minimum;
const QVariant m(d->round(minimum));
d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m));
}
@@ -792,6 +797,7 @@ double QDoubleSpinBox::maximum() const
void QDoubleSpinBox::setMaximum(double maximum)
{
Q_D(QDoubleSpinBox);
+ d->actualMax = maximum;
const QVariant m(d->round(maximum));
d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m);
}
@@ -813,6 +819,8 @@ void QDoubleSpinBox::setMaximum(double maximum)
void QDoubleSpinBox::setRange(double minimum, double maximum)
{
Q_D(QDoubleSpinBox);
+ d->actualMin = minimum;
+ d->actualMax = maximum;
d->setRange(QVariant(d->round(minimum)), QVariant(d->round(maximum)));
}
@@ -843,7 +851,7 @@ void QDoubleSpinBox::setDecimals(int decimals)
Q_D(QDoubleSpinBox);
d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG);
- setRange(minimum(), maximum()); // make sure values are rounded
+ setRange(d->actualMin, d->actualMax); // make sure values are rounded
setValue(value());
}
@@ -1051,8 +1059,10 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate()
{
- minimum = QVariant(0.0);
- maximum = QVariant(99.99);
+ actualMin = 0.0;
+ actualMax = 99.99;
+ minimum = QVariant(actualMin);
+ maximum = QVariant(actualMax);
value = minimum;
singleStep = QVariant(1.0);
decimals = 2;