aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-05 11:21:29 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-14 08:47:53 +0000
commit1457df74f4c1d770e1e820de8cd082be1bd2489e (patch)
tree9a6a637ee9304607e0cab1163db9c4c9479f0352 /tests
parent70513c7496dabf504132dd5c900cd85b367bd1b7 (diff)
Add QQuickItem acceptTouchEvents/setAcceptTouchEvents; require for touch
It has been suboptimal to speculatively deliver touch events to Items which are not interested; even worse is when we must deliver to a parent item which is filtering events, when the child Item will not accept the touch event anyway. So now it is required that any QQuickItem subclass which wishes to accept touch events must call setAcceptTouchEvents(true) (typically in its constructor). If it does not do this, it will not get any touch events (and this saves us the trouble of looking for parents which filter touch events, too). It is consistent with needing to call setAcceptHoverEvents() to get hover events, and setAcceptedMouseButtons() to get mouse events. [ChangeLog][QtQuick][QQuickItem] When subclassing QQuickItem, it is now required to call setAcceptTouchEvents(true) if you need the item to receive touch events. Change-Id: Idc76c04f4e7f1d4a613087e756e96dac368f4f23 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp4
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp10
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp1
3 files changed, 10 insertions, 5 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index ef6e444580..b37bb03305 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -63,7 +63,9 @@ public:
, touchReleases(0)
, ungrabs(0)
, m_active(false)
- { }
+ {
+ setAcceptTouchEvents(true);
+ }
QPointF pos() const { return m_pos; }
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 10a3a0bfa8..dbfe97d640 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -46,10 +46,12 @@ class TestItem : public QQuickItem
Q_OBJECT
public:
TestItem(QQuickItem *parent = 0)
- : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
- , wheelCount(0), acceptIncomingTouchEvents(true)
- , touchEventReached(false), timestamp(0)
- , lastWheelEventPos(0, 0), lastWheelEventGlobalPos(0, 0) {}
+ : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
+ , wheelCount(0), acceptIncomingTouchEvents(true)
+ , touchEventReached(false), timestamp(0)
+ , lastWheelEventPos(0, 0), lastWheelEventGlobalPos(0, 0) {
+ setAcceptTouchEvents(true);
+ }
bool focused;
int pressCount;
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index 6e7fce6189..6f5c9a37d5 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -74,6 +74,7 @@ public:
: QQuickItem(parent), touchUngrabCount(0), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1)
{
setAcceptedMouseButtons(Qt::LeftButton);
+ setAcceptTouchEvents(true);
}
void touchEvent(QTouchEvent *event)