summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qpushbutton.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-01-22 13:51:01 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-01-28 22:26:26 +0100
commit6e1d70ae12baae4610356ec7b69635ad75a97b4e (patch)
treefa84a818aabe41389544c2fa05ac2ca4b2ff6bb6 /src/widgets/widgets/qpushbutton.h
parent94bc57213f9a8a74e9e7520de68d7bba7f42ea4c (diff)
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 <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qpushbutton.h')
-rw-r--r--src/widgets/widgets/qpushbutton.h1
1 files changed, 1 insertions, 0 deletions
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: