From 05e073deebfd38103f283f8698d47a6d4a76737e Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 9 Mar 2015 15:16:28 +0100 Subject: QDoubleSpinBox: Set back an upper limit width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The limit has been removed in the change a317ee0a6fa76d1166f6da8593d39eaf7afce83c. Task-number: QTBUG-44865 Change-Id: I7106f7e7a2653e1ab03d79861ac505d4666598eb Reviewed-by: J-P Nurmi Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/widgets/qabstractspinbox.cpp | 17 +++++++++++++---- src/widgets/widgets/qspinbox.cpp | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 2f833499d9..c96c779d6a 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -848,10 +848,15 @@ QSize QAbstractSpinBox::sizeHint() const int w = 0; QString s; QString fixedContent = d->prefix + d->suffix + QLatin1Char(' '); - s = d->textFromValue(d->minimum) + fixedContent; + s = d->textFromValue(d->minimum); + s.truncate(18); + s += fixedContent; w = qMax(w, fm.width(s)); - s = d->textFromValue(d->maximum) + fixedContent; + s = d->textFromValue(d->maximum); + s.truncate(18); + s += fixedContent; w = qMax(w, fm.width(s)); + if (d->specialValueText.size()) { s = d->specialValueText; w = qMax(w, fm.width(s)); @@ -884,9 +889,13 @@ QSize QAbstractSpinBox::minimumSizeHint() const QString s; QString fixedContent = d->prefix + QLatin1Char(' '); - s = d->textFromValue(d->minimum) + fixedContent; + s = d->textFromValue(d->minimum); + s.truncate(18); + s += fixedContent; w = qMax(w, fm.width(s)); - s = d->textFromValue(d->maximum) + fixedContent; + s = d->textFromValue(d->maximum); + s.truncate(18); + s += fixedContent; w = qMax(w, fm.width(s)); if (d->specialValueText.size()) { diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 39f0b24307..457e2e1e4c 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -587,6 +587,9 @@ void QSpinBox::fixup(QString &input) const choice in addition to the range of numeric values. See setSpecialValueText() for how to do this with QDoubleSpinBox. + \note The displayed value of the QDoubleSpinBox is limited to 18 characters + in addition to eventual prefix and suffix content. This limitation is used + to keep the double spin box usable even with extremely large values. \sa QSpinBox, QDateTimeEdit, QSlider, {Spin Boxes Example} */ -- cgit v1.2.3