105 int correctedValue = newValue;
106 if (q->isComponentComplete())
107 correctedValue = boundValue(newValue, allowWrap);
109 if (modified == ValueStatus::Unmodified && newValue == correctedValue && newValue == value)
112 const bool emitSignals = (value != correctedValue);
113 value = correctedValue;
122 emit q->valueChanged();
123 if (modified == ValueStatus::Modified)
124 emit q->valueModified();
148 QQuickTextInput *inputTextItem = qobject_cast<QQuickTextInput *>(q->contentItem());
151 QString text = inputTextItem->text();
152#if QT_CONFIG(validator)
153 if (validator && live)
154 validator->fixup(text);
158 const int enteredVal = evaluateValueFromText(text);
159 const int correctedValue = boundValue(enteredVal,
false);
160 if (correctedValue == enteredVal && correctedValue != value) {
163 q->setValue(correctedValue);
168 setDisplayText(text);
173 Q_Q(
const QQuickSpinBox);
176 QQmlEngine *engine = qmlEngine(q);
177 if (engine && textFromValue.isCallable()) {
179#if QT_CONFIG(qml_locale)
180 loc = QJSValuePrivate::fromReturnedValue(
181 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
183 text = textFromValue.call(QJSValueList() << val << loc).toString();
185 text = locale.toString(val);
192 Q_Q(
const QQuickSpinBox);
194 QQmlEngine *engine = qmlEngine(q);
195 if (engine && valueFromText.isCallable()) {
197#if QT_CONFIG(qml_locale)
198 loc = QJSValuePrivate::fromReturnedValue(
199 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
201 value = valueFromText.call(QJSValueList() << text << loc).toInt();
203 value = locale.toInt(text);
498void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
501 if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
502 disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged,
this, &QQuickSpinBox::inputMethodComposingChanged);
503 QObjectPrivate::disconnect(oldInput, &QQuickTextInput::textChanged, d, &QQuickSpinBoxPrivate::contentItemTextChanged);
507 newItem->setActiveFocusOnTab(
true);
509 newItem->forceActiveFocus(
static_cast<Qt::FocusReason>(d->focusReason));
512 newItem->setCursor(Qt::IBeamCursor);
515 if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
516 connect(newInput, &QQuickTextInput::inputMethodComposingChanged,
this, &QQuickSpinBox::inputMethodComposingChanged);
517 QObjectPrivate::connect(newInput, &QQuickTextInput::textChanged, d, &QQuickSpinBoxPrivate::contentItemTextChanged);