diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2018-06-16 20:58:01 +0200 |
---|---|---|
committer | André Hartmann <aha_1980@gmx.de> | 2018-06-22 06:33:23 +0000 |
commit | f731ed9bcf7c359a3387b5bb2fb491c8ef96fae3 (patch) | |
tree | 25cc806213ef55cbbb6237a8f1a2183ad3e584c3 /src/corelib/tools/qstring.cpp | |
parent | 67776febd50bba009bd806365b4e94a851c31548 (diff) |
QString: Harmonize the toFloat() and toDouble() documentation
Both use QLocale::toDouble behind the scenes, so the same limitations
apply. Document them for toFloat() also.
Change-Id: I954362a0db203630685c034df6a921fa6447a509
Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3787c496b2..a737d70a9c 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -7207,21 +7207,30 @@ double QString::toDouble(bool *ok) const /*! Returns the string converted to a \c float value. + Returns 0.0 if the conversion fails. + If a conversion error occurs, *\a{ok} is set to \c false; otherwise - *\a{ok} is set to \c true. Returns 0.0 if the conversion fails. + *\a{ok} is set to \c true. - This function ignores leading and trailing whitespace. + \warning The QString content may only contain valid numerical characters + which includes the plus/minus sign, the characters g and e used in scientific + notation, and the decimal point. Including the unit or additional characters + leads to a conversion error. The string conversion will always happen in the 'C' locale. For locale dependent conversion use QLocale::toFloat() + For historical reasons, this function does not handle + thousands group separators. If you need to convert such numbers, + use QLocale::toFloat(). + Example: \snippet qstring/main.cpp 71 This function ignores leading and trailing whitespace. - \sa number(), toDouble(), toInt(), QLocale::toFloat() + \sa number(), toDouble(), toInt(), QLocale::toFloat(), trimmed() */ float QString::toFloat(bool *ok) const |