From 162926414d2586bdf32f7bc61860772d598beaeb Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 15 Nov 2012 17:38:29 +0100 Subject: Fix incorrect size hint for abstract spinbox This size hint was based on strange logic from an alternate universe. The size hint should only contain the text size and let the style add what is neccessary for the frame rect etc. Most styles have worked around this by simply ignoring it, however some styles could still break a bit. Note that we add 4 since that is the constant that the old code 'usually' ended up at and should be compatible with our existing styles. Change-Id: Iebdbcb8949dd8b7daa7d8cb96ae5ab7351e4f79d Reviewed-by: J-P Nurmi --- src/widgets/widgets/qabstractspinbox.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 845cb5dbd0..c48d7172ab 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -825,7 +825,7 @@ QSize QAbstractSpinBox::sizeHint() const ensurePolished(); const QFontMetrics fm(fontMetrics()); - int h = d->edit->sizeHint().height(); + int h = d->edit->sizeHint().height() + 4; int w = 0; QString s; s = d->prefix + d->textFromValue(d->minimum) + d->suffix + QLatin1Char(' '); @@ -843,17 +843,6 @@ QSize QAbstractSpinBox::sizeHint() const QStyleOptionSpinBox opt; initStyleOption(&opt); QSize hint(w, h); - QSize extra(35, 6); - opt.rect.setSize(hint + extra); - extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, - QStyle::SC_SpinBoxEditField, this).size(); - // get closer to final result by repeating the calculation - opt.rect.setSize(hint + extra); - extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, - QStyle::SC_SpinBoxEditField, this).size(); - hint += extra; - - opt.rect = rect(); d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) .expandedTo(QApplication::globalStrut()); } -- cgit v1.2.3