From 1e3833bed8a661ee8ae284188a23bd0ffc3bed85 Mon Sep 17 00:00:00 2001 From: John Layt Date: Sun, 22 Jan 2012 21:23:50 +0000 Subject: QString: Make convert to number methods only use C locale Ensure consistent conversions by not using the system default locale. Change-Id: I60db9fc4f465c0254f3213419e57d7879aaddd65 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- doc/src/snippets/qstring/main.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/src/snippets/qstring/main.cpp b/doc/src/snippets/qstring/main.cpp index 48bfea9e53..d0a445731c 100644 --- a/doc/src/snippets/qstring/main.cpp +++ b/doc/src/snippets/qstring/main.cpp @@ -737,20 +737,15 @@ void Widget::toDoubleFunction() d = QString( "1234.56e-02" ).toDouble(&ok); // ok == true, d == 12.3456 //! [67] - //! [68] //! [69] - QLocale::setDefault(QLocale::C); - d = QString( "1234,56" ).toDouble(&ok); // ok == false //! [68] + d = QString( "1234,56" ).toDouble(&ok); // ok == false d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 + //! [68] - //! [69] //! [70] - QLocale::setDefault(QLocale::German); - d = QString( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56 - d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 - - //! [70] - QLocale::setDefault(QLocale::C); + //! [69] d = QString( "1,234,567.89" ).toDouble(&ok); // ok == false + d = QString( "1234567.89" ).toDouble(&ok); // ok == true + //! [69] } void Widget::toFloatFunction() -- cgit v1.2.3