From 757a9c21c18faad5573308d8dd85428a4519ac7d Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 12 Sep 2020 17:05:10 +0200 Subject: QStyleSheetStyle: Fix push button hit testing with padding Amends f9940b15f7f0fde731431626172939b9821fd660, which amended 6e1d70ae12baae4610356ec7b69635ad75a97b4e. The bevel of the button is not defined by the contentsRect, but by the borderRect that the stylesheet style calculates. Change-Id: I9a0d5bf29a06ce2270014f0d144e33cc3a1a7473 Pick-to: 5.15 Fixes: QTBUG-86587 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 7b4e85f823..d3314494d5 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -686,7 +686,12 @@ void tst_QPushButton::hitButton() QVBoxLayout *layout = new QVBoxLayout; PushButton *button1 = new PushButton("Ok"); PushButton *button2 = new PushButton("Cancel"); - button2->setStyleSheet("QPushButton { margin: 10px; border-radius: 4px; border: 1px solid black; }"); + button2->setStyleSheet("QPushButton {" + "padding: 5px;" + "margin: 5px;" + "border-radius: 4px;" + "border: 1px solid black; }" + ); layout->addWidget(button1); layout->addWidget(button2); @@ -700,7 +705,8 @@ void tst_QPushButton::hitButton() const QPoint button2Center = button2->rect().center(); QVERIFY(button2->hitButton(button2Center)); - QVERIFY(!button2->hitButton(QPoint(0, 0))); + QVERIFY(button2->hitButton(QPoint(6, 6))); + QVERIFY(!button2->hitButton(QPoint(2, 2))); } QTEST_MAIN(tst_QPushButton) -- cgit v1.2.3