Windows11Style: don't draw progressbar label for vertical progressbars

Since the label of a progressbar is drawn right of the bar, it does not
make sense to draw a label for vertical bars. This is consistent with
windows and windowsvista style.

Pick-to: 6.8
Fixes: QTBUG-132459
Change-Id: I6610a1ef1b4074a6301aac12928c1dfe99ffd457
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit a37606310e397e13dba223dc858555c9f26ce9b6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2025-03-21 22:20:58 +01:00 committed by Qt Cherry-pick Bot
parent e2977d2e97
commit 33eb981101

View File

@ -1373,9 +1373,12 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
break; break;
case QStyle::CE_ProgressBarLabel: case QStyle::CE_ProgressBarLabel:
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) { if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
QRect rect = subElementRect(SE_ProgressBarLabel, progbaropt, widget); const bool vertical = !(progbaropt->state & QStyle::State_Horizontal);
painter->setPen(progbaropt->palette.text().color()); if (!vertical) {
painter->drawText(rect, progbaropt->text,progbaropt->textAlignment); QRect rect = subElementRect(SE_ProgressBarLabel, progbaropt, widget);
painter->setPen(progbaropt->palette.text().color());
painter->drawText(rect, progbaropt->text, progbaropt->textAlignment);
}
} }
break; break;
case CE_PushButtonLabel: case CE_PushButtonLabel: