From 75fd0f3ba9f1b2aebe63184f92039af875073119 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 27 Dec 2024 14:04:36 +0100 Subject: [PATCH] QStyleSheetStyle: Honor box settings for QSpinBox The previous patch to not modify the CT_SpinBox by QStyleSheet when nothing was added for QStylesheet also removed the additional margins & paddings handling for the size calculation. This patch re-adds this. This amends 96adebed606cdbc73c73778917d777dc04c6e93e. Task-number: QTBUG-130642 Fixes: QTBUG-132431 Change-Id: Iff1f0febeca90d3154e61fd80e4b359bc7766b84 Reviewed-by: Volker Hilsheimer Reviewed-by: Axel Spoerl (cherry picked from commit b2cc8824ec2cdeb6e053a2ff92d7d5b71f8d0ee5) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit e23933e868949b823b1f3f18706dcc3a7245d28f) --- src/widgets/styles/qstylesheetstyle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8390e352f09..f5981da4593 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -5299,9 +5299,9 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op #if QT_CONFIG(spinbox) case CT_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { - if (rule.baseStyleCanDraw()) - return baseStyle()->sizeFromContents(ct, opt, sz, w); - if (spinbox->buttonSymbols != QAbstractSpinBox::NoButtons) { + if (rule.baseStyleCanDraw()) { + sz = baseStyle()->sizeFromContents(ct, opt, sz, w); + } else if (spinbox->buttonSymbols != QAbstractSpinBox::NoButtons) { // Add some space for the up/down buttons QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); if (subRule.hasDrawable()) {