From d8ed81002994948d42831436da65488c23d8db9a Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Wed, 6 Nov 2024 11:57:25 +0100 Subject: [PATCH] QWindows11Style: Draw QRadioButton with QPainterPath The drawing of QRadioButton in QWindows11Style was performed with overdrawing, leading to problems with the transparent background color for QGraphicsWidgets. This patch draws the ring of the RadioButton using QPainterPath, to avoid overdrawing. Fixes: QTBUG-130828 Change-Id: I4b278f7f720b55e11c550977b666410d85b65382 Reviewed-by: Christian Ehrlicher (cherry picked from commit 57361de3a9814808bb575f8d01c1b12cbed9dbe9) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/modernwindows/qwindows11style.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 3835e2cdc5d..cb142aaaf3e 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -881,6 +881,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption option->styleObject->setProperty("_q_inner_radius", option->styleObject->property("_q_end_radius")); int innerRadius = option->styleObject->property("_q_inner_radius").toFloat(); + QPainterPath path; QRectF rect = option->rect; QPointF center = QPoint(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); rect.setWidth(15); @@ -893,18 +894,14 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption painter->setPen(Qt::NoPen); painter->setBrush(option->palette.accent()); - if (option->state & State_MouseOver && option->state & State_Enabled) - painter->setBrush(QBrush(option->palette.accent().color().lighter(107))); - painter->drawEllipse(center, 7, 7); + path.addEllipse(center,7,7); + path.addEllipse(center,innerRadius,innerRadius); + painter->drawPath(path); painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][frameColorStrong])); painter->setBrush(Qt::NoBrush); painter->drawEllipse(center, 7.5, 7.5); - painter->setPen(Qt::NoPen); - painter->setBrush(QBrush(option->palette.window())); - painter->drawEllipse(center,innerRadius, innerRadius); - painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][frameColorStrong])); painter->setBrush(Qt::NoBrush); painter->drawEllipse(center,innerRadius + 0.5, innerRadius + 0.5);