diff options
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-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 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 */ |