summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-17 19:58:58 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-18 16:31:27 +0100
commit2614347ab8aa0ec0b1ea8f383ae795cfdb6ae2ac (patch)
tree085530b53665d9a6f3f2889760271867934aa222 /src/widgets/styles/qcommonstyle.cpp
parentf2d752c59f5a1d2e815394d718350d0fcaf43ef6 (diff)
Fix QSpinbox default width
After aa8d3f90a440575deef914916299b792105d7209 the default width of the spinbox buttons is calculated from the spinbox width. This is wrong because the initial width (e.g. when the spinbox is not yet shown) is 640 pixels which results in a too long width. Therefore fall back to the old hard-coded value version but instead using 20 pixels, use 16 to be in sync with the stylesheet style value and honor the dpi of the screen by using QStyleHelper::dpiScaled(). Fixes: QTBUG-79806 Fixes: QTBUG-80814 Change-Id: I45786684575273f940e498df3b7639e626f00a7e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 03081658bb..49b92a69f8 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5027,8 +5027,9 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
// Add button + frame widths
+ const qreal dpi = QStyleHelper::dpi(opt);
const bool hasButtons = (vopt->buttonSymbols != QAbstractSpinBox::NoButtons);
- const int buttonWidth = hasButtons ? proxy()->subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp, widget).width() : 0;
+ const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0;
const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0;
sz += QSize(buttonWidth + 2*fw, 2*fw);
}