diff options
Diffstat (limited to 'src/qml/doc/src/javascript/number.qdoc')
-rw-r--r-- | src/qml/doc/src/javascript/number.qdoc | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/src/qml/doc/src/javascript/number.qdoc b/src/qml/doc/src/javascript/number.qdoc index 288232255c..a37fd8051b 100644 --- a/src/qml/doc/src/javascript/number.qdoc +++ b/src/qml/doc/src/javascript/number.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** 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. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \qmltype Number @@ -58,21 +34,32 @@ If \a locale is not specified, the default locale will be used. The following example shows a number formatted for the German locale: - \code + \qml import QtQuick 2.0 Text { text: "The value is: " + Number(4742378.423).toLocaleString(Qt.locale("de_DE")) } - \endcode + \endqml + + You can customize individual fields of the \a{locale} to tightly control + the output: + \qml + let locale = Qt.locale("de_DE"); + let a = Number(1000).toLocaleString(locale)); // a == 1.000,00 + locale.numberOptions = Locale.OmitGroupSeparator; + let b = Number(1000).toLocaleString(locale)); // b == 1000,00 + \endqml You can apply toLocaleString() directly to constants, provided the decimal is included in the constant, e.g. - \code + \qml 123.0.toLocaleString(Qt.locale("de_DE")) // OK 123..toLocaleString(Qt.locale("de_DE")) // OK 123.toLocaleString(Qt.locale("de_DE")) // fails - \endcode + \endqml + + \sa {QtQml::Locale}{Locale} */ /*! @@ -93,12 +80,14 @@ If \a locale is not supplied the default locale will be used. For example, using the German locale: - \code + \qml 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 + \endqml + + \sa {QtQml::Locale}{Locale} */ |