93 Q_Q(QQuickDoubleSpinBox);
94 double correctedValue = newValue;
95 if (q->isComponentComplete())
96 correctedValue = boundValue(newValue, wrap);
98 if (modified == ValueStatus::Unmodified && qFuzzyCompare(newValue, correctedValue)
99 && qFuzzyCompare(newValue, value))
102 const bool emitSignals = (value != correctedValue);
103 value = correctedValue;
112 emit q->valueChanged();
113 if (modified == ValueStatus::Modified)
114 emit q->valueModified();
146 Q_Q(
const QQuickDoubleSpinBox);
149 QQmlEngine *engine = qmlEngine(q);
150 if (engine && textFromValue.isCallable()) {
152#if QT_CONFIG(qml_locale)
153 loc = QJSValuePrivate::fromReturnedValue(
154 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
156 text = textFromValue.call(QJSValueList() << val << decimals << loc).toString();
158 text = locale.toString(val,
'f', decimals);
165 Q_Q(
const QQuickDoubleSpinBox);
167 QQmlEngine *engine = qmlEngine(q);
168 if (engine && valueFromText.isCallable()) {
170#if QT_CONFIG(qml_locale)
171 loc = QJSValuePrivate::fromReturnedValue(
172 engine->handle()->fromData(QMetaType::fromType<QLocale>(), &locale));
174 value = valueFromText.call(QJSValueList() << text << loc).toNumber();
176 value = locale.toDouble(text);
186QQuickDoubleSpinBox::QQuickDoubleSpinBox(QQuickItem *parent)
187 : QQuickControl(*(
new QQuickDoubleSpinBoxPrivate), parent),
188 QQuickAbstractSpinBox<QQuickDoubleSpinBox,
double>()
198void QQuickDoubleSpinBox::setFrom(
double from)
200 Q_D(QQuickDoubleSpinBox);
201 const double newFrom = d->round(from);
202 if (qFuzzyCompare(d->from, newFrom))
207 if (isComponentComplete()) {
208 if (!d->setValue(d->round(d->value),
false ,
209 QQuickDoubleSpinBoxPrivate::ValueStatus::Unmodified)) {
210 d->updateUpEnabled();
211 d->updateDownEnabled();
220void QQuickDoubleSpinBox::setTo(
double to)
222 Q_D(QQuickDoubleSpinBox);
223 const double newTo = d->round(to);
224 if (qFuzzyCompare(d->to, newTo))
229 if (isComponentComplete()) {
230 if (!d->setValue(d->round(d->value),
false ,
231 QQuickDoubleSpinBoxPrivate::ValueStatus::Unmodified)) {
232 d->updateUpEnabled();
233 d->updateDownEnabled();
242void QQuickDoubleSpinBox::setValue(
double value)
244 Q_D(QQuickDoubleSpinBox);
245 d->setValue(d->round(value),
false ,
246 QQuickDoubleSpinBoxPrivate::ValueStatus::Unmodified);
470void QQuickDoubleSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
472 Q_D(QQuickDoubleSpinBox);
473 if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
474 disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged,
this,
475 &QQuickDoubleSpinBox::inputMethodComposingChanged);
476 QObjectPrivate::disconnect(oldInput, &QQuickTextInput::textChanged, d,
477 &QQuickDoubleSpinBoxPrivate::contentItemTextChanged);
481 newItem->setActiveFocusOnTab(
true);
483 newItem->forceActiveFocus(
static_cast<Qt::FocusReason>(d->focusReason));
486 newItem->setCursor(Qt::IBeamCursor);
489 if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
490 connect(newInput, &QQuickTextInput::inputMethodComposingChanged,
this,
491 &QQuickDoubleSpinBox::inputMethodComposingChanged);
492 QObjectPrivate::connect(newInput, &QQuickTextInput::textChanged, d,
493 &QQuickDoubleSpinBoxPrivate::contentItemTextChanged);