QAbstractSpinBox: honor QAbstractSpinBox::NoButtons in sizeHint()

QCommonStyle::sizeFromContents() did not check if a spinbox has buttons
or not and returned a to wide width when no buttons are displayed.

Task-number: QTBUG-67126
Change-Id: I9f97a31a89a0986023316b02e11017e620c0f614
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
bb10
Christian Ehrlicher 2018-03-29 19:25:40 +02:00
parent 17f4d159a9
commit 6e8ac90539
1 changed files with 2 additions and 2 deletions

View File

@ -4934,8 +4934,8 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
// Add button + frame widths
int buttonWidth = 20;
int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0;
const int buttonWidth = (vopt->subControls & (QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown)) != 0 ? 20 : 0;
const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0;
sz += QSize(buttonWidth + 2*fw, 2*fw);
}
break;