diff options
author | Andy Shaw <andy.shaw@digia.com> | 2015-12-02 09:51:35 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2017-11-06 23:56:16 +0000 |
commit | 37d25a5112cdf13620715c03d6bdbd1bc3cde515 (patch) | |
tree | b1621e308555d25ab0c08df64e8e2fc34ce54eaf /tests | |
parent | 5fc892ef86870021ad11d0be6981aa9630c1c01c (diff) |
QQuickWidget: pass enter and leave events to the offscreen window
By passing the enter and leave events to the offscreen window it will
enable mouse areas inside a QQuickWidget to know when the mouse has
actually entered or left the area if it is covering the whole item.
Task-number: QTBUG-45557
Change-Id: I670ebe30e367e919c73fed449bf2bed7ca42b5fd
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quickwidgets/qquickwidget/data/enterleave.qml | 12 | ||||
-rw-r--r-- | tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quickwidgets/qquickwidget/data/enterleave.qml b/tests/auto/quickwidgets/qquickwidget/data/enterleave.qml new file mode 100644 index 0000000000..b3057e30ad --- /dev/null +++ b/tests/auto/quickwidgets/qquickwidget/data/enterleave.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + property bool hasMouse: mouseArea.containsMouse + height: 200 + width: 200 + MouseArea { + id: mouseArea + hoverEnabled: true + anchors.fill: parent + } +} diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index ee49c9c7ad..e4991a5f26 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -61,6 +61,7 @@ private slots: void nullEngine(); void keyEvents(); void shortcuts(); + void enterLeave(); }; @@ -408,6 +409,30 @@ void tst_qquickwidget::shortcuts() QTRY_VERIFY(filter.shortcutOk); } +void tst_qquickwidget::enterLeave() +{ + QQuickWidget view; + view.setSource(testFileUrl("enterleave.qml")); + + // Ensure it is not inside the window first + QCursor::setPos(QPoint(50, 50)); + QTRY_VERIFY(QCursor::pos() == QPoint(50, 50)); + + view.move(100, 100); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view, 5000)); + QQuickItem *rootItem = view.rootObject(); + QVERIFY(rootItem); + + QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); + // Check the enter + QCursor::setPos(view.pos() + QPoint(50, 50)); + QTRY_VERIFY(rootItem->property("hasMouse").toBool()); + // Now check the leave + QCursor::setPos(view.pos() - QPoint(50, 50)); + QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" |