diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 2a81006657a..8a92bef1b74 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -9,6 +9,7 @@ #include "private/qobject_p.h" #include "private/qlocale_p.h" #include "private/qnumeric_p.h" +#include "private/qstringiterator_p.h" #include #include @@ -757,8 +758,19 @@ void QDoubleValidatorPrivate::fixupWithLocale(QString &input, QLocaleData::Numbe if (numMode == QLocaleData::DoubleStandardMode) { mode = 'f'; } else { - // scientific mode can be either 'e' or 'E' - mode = input.contains(QChar::fromLatin1('E')) ? 'E' : 'e'; + // Scientific mode can be either 'e' or 'E' + const QString exp = locale.exponential(); + bool preferUpper = false; + QStringIterator scan(exp); + while (!preferUpper && scan.hasNext()) { + const char32_t ch = scan.next(); + if (QChar::isUpper(ch)) + preferUpper = true; + } + if (preferUpper) + mode = input.contains(exp.toLower()) ? 'e' : 'E'; + else // If case-free, we don't care which we use; otherwise, prefer lower. + mode = input.contains(exp.toUpper()) ? 'E' : 'e'; } int precision; if (q->dec < 0) {