Fusion style: adjust sizeFromContents() for CT_PushButton

Move the text a little bit further away from the horizontal border.

[ChangeLog][QtWidgets][Styles] PM_ButtonMargin is now respected for
QPushButton in fusion style.

Fixes: QTBUG-94860
Change-Id: I2447de0b8fca048eb2efe1a309969fad61f6bd29
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Christian Ehrlicher 2024-11-06 20:02:13 +01:00 committed by Volker Hilsheimer
parent f1fd15b454
commit bc80707387

View File

@ -2916,6 +2916,8 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
switch (type) {
case CT_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
const int horizontalMargin = pixelMetric(PM_ButtonMargin, btn);
newSize += QSize(horizontalMargin, 0);
if (!btn->text.isEmpty() && newSize.width() < 80)
newSize.setWidth(80);
if (!btn->icon.isNull() && btn->iconSize.height() > 16)