From 05f7dd5ead5927ef7b3301380b81d7194d9e0593 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Tue, 4 May 2021 12:13:39 +0200 Subject: Don't draw focus frame if widget has style rules that affect border Skip drawing the focus ring if the widget has a custom styled border, custom focus ring, or any rule that affects the border. For QPushButton, if the style rule has a background set, the bevel will be drawn in the Windows style. Skip drawing the Mac focus frame in that case too. Fixes: QTBUG-93032 Pick-to: 5.15 6.1 Change-Id: I7c4d4bf6f6ce7bbcd17cd620586c5efa44f2b8d6 Reviewed-by: Volker Hilsheimer --- src/widgets/styles/qstylesheetstyle.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 04a3b3a352..a45401fd1f 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -123,6 +123,9 @@ #if QT_CONFIG(toolbar) #include #endif +#if QT_CONFIG(pushbutton) +#include +#endif #include #include @@ -2943,6 +2946,12 @@ void QStyleSheetStyle::polish(QWidget *w) if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox() || (!rule.hasNativeBorder() && !rule.border()->isOpaque())) w->setAttribute(Qt::WA_OpaquePaintEvent, false); + if (rule.hasBox() || !rule.hasNativeBorder() +#if QT_CONFIG(pushbutton) + || (qobject_cast(w)) +#endif + ) + w->setAttribute(Qt::WA_MacShowFocusRect, false); } } -- cgit v1.2.3