aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/declarative/qmlnumber.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/declarative/qmlnumber.qdoc')
-rw-r--r--doc/src/declarative/qmlnumber.qdoc105
1 files changed, 105 insertions, 0 deletions
diff --git a/doc/src/declarative/qmlnumber.qdoc b/doc/src/declarative/qmlnumber.qdoc
new file mode 100644
index 0000000000..0b4341d76b
--- /dev/null
+++ b/doc/src/declarative/qmlnumber.qdoc
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlclass Number
+ \inqmlmodule QtQuick 2
+ \brief The Number object provides represents a number value
+
+ The QML Number object extends the JS Number object with
+ locale aware functions.
+
+ \sa {QtQuick2::Locale}{Locale}
+*/
+
+/*!
+ \qmlmethod string Number::toLocaleString(locale,format,precision)
+
+ Converts the Number to a string suitable for the specified \a locale
+ in the specified \a format, with the specified \a precision.
+
+ Valid formats are:
+ \list
+ \o 'f' Decimal floating point, e.g. 248.65
+ \o 'e' Scientific notation using e character, e.g. 2.4865e+2
+ \o 'E' Scientific notation using E character, e.g. 2.4865E+2
+ \o 'g' Use the shorter of e or f
+ \o 'G' Use the shorter of E or f
+ \endlist
+
+ If precision is not specified, the precision will be 2.
+
+ If the format is not specified 'f' will be used.
+
+ If \a locale is not specified, the default locale will be used.
+
+ The following example shows a number formatted for the German locale:
+ \code
+ import QtQuick 2.0
+
+ Text {
+ text: "The value is: " + Number(4742378.423).toLocaleString(Qt.locale("de_DE"))
+ }
+ \endcode
+
+ You can apply toLocaleString() directly to constants, provided the decimal
+ is included in the constant, e.g.
+ \code
+ 123.0.toLocaleString(Qt.locale("de_DE")) // OK
+ 123..toLocaleString(Qt.locale("de_DE")) // OK
+ 123.toLocaleString(Qt.locale("de_DE")) // fails
+ \endcode
+*/
+
+/*!
+ \qmlmethod string Number::toLocaleCurrencyString(locale,symbol)
+
+ Converts the Number to a currency using the currency and conventions of the specified
+ \a locale. If \a symbol is specified it will be used as the currency
+ symbol.
+
+ \sa Locale::currencySymbol()
+*/
+
+/*!
+ \qmlmethod string Number::fromLocaleString(locale,number)
+
+ Returns a Number by parsing \a number using the conventions of the supplied \a locale.
+
+ If \a locale is not supplied the default locale will be used.
+
+ For example, using the German locale:
+ \code
+ var german = Qt.locale("de_DE");
+ var d;
+ d = Number.fromLocaleString(german, "1234,56) // d == 1234.56
+ d = Number.fromLocaleString(german, "1.234,56") // d == 1234.56
+ d = Number.fromLocaleString(german, "1234.56") // throws exception
+ d = Number.fromLocaleString(german, "1.234") // d == 1234.0
+ \endcode
+*/
+