diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-10 09:24:35 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-10 09:24:35 (GMT) |
commit | f9128d973f60e225045bebb97a19d292395b865d (patch) | |
tree | a4187825446ad8c7734407634843ee95379346b9 /src | |
parent | 00cc4c9cfc83fa2a20fc72712c7caf9f8bc6f7bb (diff) | |
download | Qt-f9128d973f60e225045bebb97a19d292395b865d.zip Qt-f9128d973f60e225045bebb97a19d292395b865d.tar.gz Qt-f9128d973f60e225045bebb97a19d292395b865d.tar.bz2 |
QDoubleSpinBox: make sure people can't choose too many decimals
Maximum number of decimals is DBL_MAX_10_EXP + DBL_DIG
Task-number: 257291
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qspinbox.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index e069a21..3933272 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -50,6 +50,7 @@ #include <qdebug.h> #include <math.h> +#include <float.h> QT_BEGIN_NAMESPACE @@ -823,8 +824,8 @@ void QDoubleSpinBox::setRange(double minimum, double maximum) Sets how many decimals the spinbox will use for displaying and interpreting doubles. - \warning The results might not be reliable with very high values - for \a decimals. + \warning The maximum value for \a decimals is DBL_MAX_10_EXP + + DBL_DIG (ie. 323) because of the limitations of the double type. Note: The maximum, minimum and value might change as a result of changing this property. @@ -840,7 +841,7 @@ int QDoubleSpinBox::decimals() const void QDoubleSpinBox::setDecimals(int decimals) { Q_D(QDoubleSpinBox); - d->decimals = qMax(0, decimals); + d->decimals = qBound(0, decimals, DBL_MAX_10_EXP + DBL_DIG); setRange(minimum(), maximum()); // make sure values are rounded setValue(value()); |