diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-01-30 12:33:51 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-03-29 15:05:25 +0000 |
commit | 8d49df2172aaffaf49fbad0bc4d522d34662b583 (patch) | |
tree | bac6b0a7b71781ccb2339e37774c8ee1258869bf /src/corelib/doc/snippets | |
parent | 46351b4e601ee0e87c4a8467785c1e5718565190 (diff) |
QLocale: add QStringView overload of number parsing functions
This ports all to<Integer>() functions in QLocale to QStringView.
Change-Id: Idc3f026d5afdf51abab670b54ea96d2361cdc350
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp index 3794049f97..aed14c379f 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlocale.cpp @@ -103,3 +103,20 @@ d = german.toDouble( "1234.56", &ok ); // ok == false d = german.toDouble( "1.234", &ok ); // ok == true, d == 1234.0 //! [3] + +//! [3-qstringview] +bool ok; +double d; + +QLocale c(QLocale::C); +d = c.toDouble(u"1234.56", &ok); // ok == true, d == 1234.56 +d = c.toDouble(u"1,234.56", &ok); // ok == true, d == 1234.56 +d = c.toDouble(u"1234,56", &ok); // ok == false + +QLocale german(QLocale::German); +d = german.toDouble(u"1234,56", &ok); // ok == true, d == 1234.56 +d = german.toDouble(u"1.234,56", &ok); // ok == true, d == 1234.56 +d = german.toDouble(u"1234.56", &ok); // ok == false + +d = german.toDouble(u"1.234", &ok); // ok == true, d == 1234.0 +//! [3-qstringview] |