QStyleSheetStyle: Don't calc size for CT_SpinBox when not handled

Let the size for CT_SpinBox be calculated by the base style when
QStyleSheetStyle does not draw the spinbox. This makes sure the returned
size matches the size needed by the style which draws the spinbox later
on.

Fixes: QTBUG-130642
Change-Id: I99aca7440c4ce9800d78f76a209097a93f320cd2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 96adebed606cdbc73c73778917d777dc04c6e93e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2024-10-31 18:37:23 +01:00 committed by Qt Cherry-pick Bot
parent ced68767da
commit 168f4aee26

View File

@ -5297,6 +5297,8 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
#if QT_CONFIG(spinbox)
case CT_SpinBox:
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
if (rule.baseStyleCanDraw())
return baseStyle()->sizeFromContents(ct, opt, sz, w);
if (spinbox->buttonSymbols != QAbstractSpinBox::NoButtons) {
// Add some space for the up/down buttons
QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);