[Development] Touch not working with QtQuick1 (event handling issue in QGraphicsView)

Frank Osterfeld frank.osterfeld at kdab.com
Mon Mar 11 14:44:29 CET 2013


Hi,

I'm debugging a major issue with QtQuick1 I'm seeing with both 5.0.0 and the current stable branch: Touch events don't work with QtQuick1's MouseArea element.

As QtQuick1 items don't handle touch directly, they they rely on on the touch->mouse fallback in QApplication which creates mouse events if a touch event wasn't accepted.
That works or TouchBegin events, but fails for subsequent TouchMove and TouchEnd events as QGraphicsView silently accepts touch events if it doesn't find an item that waits for touch.

If a series of TouchBegin, TouchMove, TouchEnd events is sent to QGraphicsView containing QQ1 items, the following happens:

1) GraphicsScenePrivate::touchEventHandler receives a TouchBegin event. As the QQ1 items don't accept touch, the event is ignored. That triggers the touch-mouse fallback, which works fine.
2) GraphicsScenePrivate::touchEventHandler then receives TouchMove/TouchEnd events. The touch handler looks for items needing touch events (items which previously accepted a TouchBegin event), but doesn't find any. (because the QQ1 items received the fallback mouse events, not the touchBegin event)
In that case, it just accepts the touchMove/touchEnd event. As the event is accepted, the touch->mouse fallback in QApplication isn't triggered.

I see two ways to fix it, one is a one-liner, one's more work:

 * Don't silently accept touch events if no item is waiting for them. Ignoring the events triggers the touch->mouse fallback. That's the approach the attached patch takes and seems to work fine (tested with the QQ1 hello world example).
 * Make QQ1 items accept touch events and do the touch to mouse mapping internally

Do you see issues with the first approach? I don't see why TouchMove and TouchEnd should be accepted if not handled, but TouchBegin is ignored if not handled.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: touch-qquick1-graphicsview.diff
Type: application/octet-stream
Size: 479 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130311/6446b13f/attachment.obj>
-------------- next part --------------



-- 
Frank Osterfeld | frank.osterfeld at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel. Germany +49-30-521325470, Sweden (HQ)  +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4035 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130311/6446b13f/attachment.bin>


More information about the Development mailing list