summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qvalidator.cpp21
-rw-r--r--src/gui/util/qvalidator.h3
2 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 52dfad11a4..14d9c01503 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -591,8 +591,8 @@ public:
that accepts any double.
*/
-QDoubleValidator::QDoubleValidator(QObject * parent)
- : QDoubleValidator(-HUGE_VAL, HUGE_VAL, 1000, parent)
+QDoubleValidator::QDoubleValidator(QObject *parent)
+ : QDoubleValidator(-HUGE_VAL, HUGE_VAL, -1, parent)
{
}
@@ -801,6 +801,9 @@ void QDoubleValidatorPrivate::fixupWithLocale(QString &input, QLocaleData::Numbe
Sets the validator to accept doubles from \a minimum to \a maximum
inclusive, with at most \a decimals digits after the decimal
point.
+
+ \note Setting the number of decimals to -1 effectively sets it to unlimited.
+ This is also the value used by a default-constructed validator.
*/
void QDoubleValidator::setRange(double minimum, double maximum, int decimals)
@@ -828,6 +831,17 @@ void QDoubleValidator::setRange(double minimum, double maximum, int decimals)
}
/*!
+ \overload
+
+ Sets the validator to accept doubles from \a minimum to \a maximum
+ inclusive without changing the number of digits after the decimal point.
+*/
+void QDoubleValidator::setRange(double minimum, double maximum)
+{
+ setRange(minimum, maximum, decimals());
+}
+
+/*!
\property QDoubleValidator::bottom
\brief the validator's minimum acceptable value
@@ -860,7 +874,8 @@ void QDoubleValidator::setTop(double top)
\property QDoubleValidator::decimals
\brief the validator's maximum number of digits after the decimal point
- By default, this property contains a value of 1000.
+ By default, this property contains a value of -1, which means any number
+ of digits is accepted.
\sa setRange()
*/
diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h
index be9042d653..7728857672 100644
--- a/src/gui/util/qvalidator.h
+++ b/src/gui/util/qvalidator.h
@@ -142,7 +142,8 @@ public:
QValidator::State validate(QString &, int &) const override;
void fixup(QString &input) const override;
- void setRange(double bottom, double top, int decimals = 0);
+ void setRange(double bottom, double top, int decimals);
+ void setRange(double bottom, double top);
void setBottom(double);
void setTop(double);
void setDecimals(int);