aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickspinbox.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-19 07:58:53 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-19 09:01:43 +0200
commit124dd9adb5882048e44dcd012e08899d4e480196 (patch)
treef6022e22f08f2128df2b0cc2081c2b8843408aba /src/quicktemplates2/qquickspinbox.cpp
parent6cb2367f01c1f78d760c1a4d70002cf5a5046396 (diff)
parentd6fbb1239950f392f3d569da7dde226e865b7bcd (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml src/imports/controls/material/qquickmaterialstyle.cpp Change-Id: I00b533e28407f87a31588e92109a468a5bfb4cc8
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 72dac1c6..ec801b1a 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -456,6 +456,12 @@ void QQuickSpinBox::setValidator(QValidator *validator)
This property holds a callback function that is called whenever
an integer value needs to be converted to display text.
+ The default function can be overridden to display custom text for a given
+ value. This applies to both editable and non-editable spinboxes;
+ for example, when using the up and down buttons or a mouse wheel to
+ increment and decrement the value, the new value is converted to display
+ text using this function.
+
The callback function signature is \c {string function(value, locale)}.
The function can have one or two arguments, where the first argument
is the value to be converted, and the optional second argument is the
@@ -467,6 +473,10 @@ void QQuickSpinBox::setValidator(QValidator *validator)
textFromValue: function(value, locale) { return Number(value).toLocaleString(locale, 'f', 0); }
\endcode
+ \note When applying a custom \c textFromValue implementation for editable
+ spinboxes, a matching \l valueFromText implementation must be provided
+ to be able to convert the custom text back to an integer value.
+
\sa valueFromText, validator, {Control::locale}{locale}
*/
QJSValue QQuickSpinBox::textFromValue() const
@@ -497,6 +507,9 @@ void QQuickSpinBox::setTextFromValue(const QJSValue &callback)
This property holds a callback function that is called whenever
input text needs to be converted to an integer value.
+ This function only needs to be overridden when \l textFromValue
+ is overridden for an editable spinbox.
+
The callback function signature is \c {int function(text, locale)}.
The function can have one or two arguments, where the first argument
is the text to be converted, and the optional second argument is the
@@ -508,6 +521,10 @@ void QQuickSpinBox::setTextFromValue(const QJSValue &callback)
valueFromText: function(text, locale) { return Number.fromLocaleString(locale, text); }
\endcode
+ \note When applying a custom \l textFromValue implementation for editable
+ spinboxes, a matching \c valueFromText implementation must be provided
+ to be able to convert the custom text back to an integer value.
+
\sa textFromValue, validator, {Control::locale}{locale}
*/
QJSValue QQuickSpinBox::valueFromText() const
@@ -569,7 +586,7 @@ QQuickSpinButton *QQuickSpinBox::down() const
/*!
\qmlmethod void QtQuick.Controls::SpinBox::increase()
- Increases the value by \l stepSize.
+ Increases the value by \l stepSize, or \c 1 if stepSize is not defined.
\sa stepSize
*/
@@ -582,7 +599,7 @@ void QQuickSpinBox::increase()
/*!
\qmlmethod void QtQuick.Controls::SpinBox::decrease()
- Decreases the value by \l stepSize.
+ Decreases the value by \l stepSize, or \c 1 if stepSize is not defined.
\sa stepSize
*/