diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-10-17 15:06:58 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-10-17 16:09:51 +0000 |
commit | 18f6bec453f4046edc774edcf0d9f8e925aed2df (patch) | |
tree | d297c8d72e8a429b1bad274335ba008d2c2b2a3d /src/quicktemplates2 | |
parent | 2a7c3cb7043ef422d8c2a51b34bacc553ee4eddd (diff) |
SpinBox: fix documentation review findings
Change-Id: Id2a2531dfb1d61b02e50ee11d0e67bed1e16e09f
Task-number: QTBUG-55904
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 116d1e12..2939a0ea 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -446,6 +446,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 @@ -457,6 +463,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 @@ -487,6 +497,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 @@ -498,6 +511,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 @@ -555,7 +572,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 */ @@ -568,7 +585,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 */ |