diff options
Diffstat (limited to 'src/widgets/widgets/qspinbox.cpp')
-rw-r--r-- | src/widgets/widgets/qspinbox.cpp | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index dcf3906dd7..97a3a12336 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -128,9 +128,10 @@ public: manually. The spin box supports integer values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QSpinBox emits two valueChanged() signals, - one providing an int and the other a QString. The QString overload - provides the value with both prefix() and suffix(). + Every time the value changes QSpinBox emits valueChanged() and + textChanged() signals, the former providing a int and the latter + a QString. The textChanged() signal provides the value with both + prefix() and suffix(). The current value can be fetched with value() and set with setValue(). Clicking the up/down buttons or using the keyboard accelerator's @@ -183,12 +184,23 @@ public: */ /*! + \fn void QSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) +/*! \fn void QSpinBox::valueChanged(const QString &text) \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0 as minimum value and 99 as maximum value, a @@ -594,9 +606,9 @@ void QSpinBox::fixup(QString &input) const values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QDoubleSpinBox emits two - valueChanged() signals, one taking providing a double and the other - a QString. The QString overload provides the value with both + Every time the value changes QDoubleSpinBox emits valueChanged() and + textChanged() signals, the former providing a double and the latter + a QString. The textChanged() signal provides the value with both prefix() and suffix(). The current value can be fetched with value() and set with setValue(). @@ -644,12 +656,23 @@ void QSpinBox::fixup(QString &input) const */ /*! + \fn void QDoubleSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) +/*! \fn void QDoubleSpinBox::valueChanged(const QString &text); \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, @@ -728,6 +751,10 @@ void QDoubleSpinBox::setPrefix(const QString &prefix) d->prefix = prefix; d->updateEdit(); + + d->cachedSizeHint = QSize(); + d->cachedMinimumSizeHint = QSize(); // minimumSizeHint cares about the prefix + updateGeometry(); } /*! @@ -1068,7 +1095,13 @@ void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toInt()); } } @@ -1134,10 +1167,14 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, num = copy.toInt(&ok, displayIntegerBase); } else { num = locale.toInt(copy, &ok); - if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) { - QString copy2 = copy; - copy2.remove(locale.groupSeparator()); - num = locale.toInt(copy2, &ok); + if (!ok && (max >= 1000 || min <= -1000)) { + const QChar sep = locale.groupSeparator(); + const QChar doubleSep[2] = {sep, sep}; + if (copy.contains(sep) && !copy.contains(QString(doubleSep, 2))) { + QString copy2 = copy; + copy2.remove(locale.groupSeparator()); + num = locale.toInt(copy2, &ok); + } } } QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; @@ -1215,7 +1252,13 @@ void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toDouble()); } } |