diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-29 19:25:40 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-30 08:12:34 +0000 |
commit | 6e8ac905397bf3067631c495e568471b4f908f37 (patch) | |
tree | 8bc3612db7e02a255d8d9ea4be9de63a62a4287f /src/widgets/styles/qcommonstyle.cpp | |
parent | 17f4d159a90d477dc0c7851e73a0a1cb6a86833e (diff) |
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>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index f78aca58ac..8965f913d5 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -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; |