From 6e1d70ae12baae4610356ec7b69635ad75a97b4e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 22 Jan 2020 13:51:01 +0100 Subject: QPushButton: only trigger button when click occurs within the bevel rect On the mac, the push button's bevel doesn't cover the entire widget rectangle, but is smaller to leave space for focus frame, shadow, and in general to meet style guidelines. Without this change, a click anywhere inside the widget would activate the button. QAbstractButton::hitButton can be reimplemented to limit the area in which the button is triggered. However, getting the rectangle also requires an addition to QStyle, so that we can query QStyle::subElementRect for the actual area the button's bevel covers. As a side effect, tests that use QPushButton and assume that it responds to clicks at position 0,0 have to be fixed so that they don't fail on mac. Change-Id: I01b60a763bccf39090aee5b2369af300f922d226 Fixes: QTBUG-81452 Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qcommonstyle.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets/styles/qcommonstyle.cpp') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 1e5830d216..eb5399bd4a 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -2465,6 +2465,12 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = visualRect(opt->direction, opt->rect, r); } break; + case SE_PushButtonBevel: + { + r = opt->rect; + r = visualRect(opt->direction, opt->rect, r); + } + break; case SE_CheckBoxIndicator: { int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); -- cgit v1.2.3