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.

Pick-to: 6.8
Fixes: QTBUG-130642
Change-Id: I99aca7440c4ce9800d78f76a209097a93f320cd2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Christian Ehrlicher 2024-10-31 18:37:23 +01:00
parent deb4e08c12
commit 96adebed60
1 changed files with 2 additions and 0 deletions

View File

@ -5318,6 +5318,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);