From 17e8286fef874630cb2703bd20885c6005bf674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 14 Feb 2013 08:35:23 +0100 Subject: [PATCH] Fixed mouse double click events not bubbling up to parent widgets. The bug was caused by changes b371f3f943703840d0dfbe30505018bcca06e260 and 3bb902495291c50a2f06e8e03a62a647db3e5cd4, which removed the event forwarding that QWidget::mouseDoubleClickEvent() used to do without making sure to call ignore() on the event like QWidget::mousePressEvent() does. Task-number: QTBUG-29680 Change-Id: I98af8052ad3dd1dea15d07a710aa9212ef5e4a68 Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 2 +- .../widgets/kernel/qwidget/tst_qwidget.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 3b9e889a9c..7209d8c9ad 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8413,7 +8413,7 @@ void QWidget::mouseReleaseEvent(QMouseEvent *event) void QWidget::mouseDoubleClickEvent(QMouseEvent *event) { - Q_UNUSED(event); + event->ignore(); } #ifndef QT_NO_WHEELEVENT diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index ab1500ee32..c1927c9d1f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -411,6 +411,7 @@ private slots: void destroyedSignal(); void keyboardModifiers(); + void mouseDoubleClickBubbling_QTBUG29680(); private: bool ensureScreenSize(int width, int height); @@ -10047,5 +10048,30 @@ void tst_QWidget::keyboardModifiers() QCOMPARE(int(w->m_appModifiers), int(Qt::ControlModifier)); } +class DClickWidget : public QWidget +{ +public: + DClickWidget() : triggered(false) {} + void mouseDoubleClickEvent(QMouseEvent *) + { + triggered = true; + } + bool triggered; +}; + +void tst_QWidget::mouseDoubleClickBubbling_QTBUG29680() +{ + DClickWidget parent; + QWidget child(&parent); + parent.resize(200, 200); + child.resize(200, 200); + parent.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); + + QTest::mouseDClick(&child, Qt::LeftButton); + + QTRY_VERIFY(parent.triggered); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc"