102 int correctedValue = newValue;
103 if (q->isComponentComplete())
104 correctedValue = boundValue(newValue, allowWrap);
106 if (modified == ValueStatus::Unmodified && newValue == correctedValue && newValue == value)
109 const bool emitSignals = (value != correctedValue);
110 value = correctedValue;
119 emit q->valueChanged();
120 if (modified == ValueStatus::Modified)
121 emit q->valueModified();
145 QQuickTextInput *inputTextItem = qobject_cast<QQuickTextInput *>(q->contentItem());
148 QString text = inputTextItem->text();
149#if QT_CONFIG(validator)
150 if (validator && live)
151 validator->fixup(text);
155 const int enteredVal = evaluateValueFromText(text);
156 const int correctedValue = boundValue(enteredVal,
false);
157 if (correctedValue == enteredVal && correctedValue != value) {
160 q->setValue(correctedValue);
165 setDisplayText(text);
170 Q_Q(
const QQuickSpinBox);
173 QQmlEngine *engine = qmlEngine(q);
174 if (engine && textFromValue.isCallable()) {
176#if QT_CONFIG(qml_locale)
177 loc = QJSValuePrivate::fromReturnedValue(
178 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
180 text = textFromValue.call(QJSValueList() << val << loc).toString();
182 text = locale.toString(val);
189 Q_Q(
const QQuickSpinBox);
191 QQmlEngine *engine = qmlEngine(q);
192 if (engine && valueFromText.isCallable()) {
194#if QT_CONFIG(qml_locale)
195 loc = QJSValuePrivate::fromReturnedValue(
196 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
198 value = valueFromText.call(QJSValueList() << text << loc).toInt();
200 value = locale.toInt(text);
495void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
498 if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
499 disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged,
this, &QQuickSpinBox::inputMethodComposingChanged);
500 QObjectPrivate::disconnect(oldInput, &QQuickTextInput::textChanged, d, &QQuickSpinBoxPrivate::contentItemTextChanged);
504 newItem->setActiveFocusOnTab(
true);
506 newItem->forceActiveFocus(
static_cast<Qt::FocusReason>(d->focusReason));
509 newItem->setCursor(Qt::IBeamCursor);
512 if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
513 connect(newInput, &QQuickTextInput::inputMethodComposingChanged,
this, &QQuickSpinBox::inputMethodComposingChanged);
514 QObjectPrivate::connect(newInput, &QQuickTextInput::textChanged, d, &QQuickSpinBoxPrivate::contentItemTextChanged);