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/widgets/qpushbutton.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/widgets/qpushbutton.h') diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index b02ba63d07..283dfe2c61 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -94,6 +94,7 @@ protected: void focusInEvent(QFocusEvent *) override; void focusOutEvent(QFocusEvent *) override; void initStyleOption(QStyleOptionButton *option) const; + bool hitButton(const QPoint &pos) const override; QPushButton(QPushButtonPrivate &dd, QWidget* parent = nullptr); public: -- cgit v1.2.3