[Interest] Two single touch areas

Rutledge Shawn Shawn.Rutledge at digia.com
Thu Apr 11 08:07:22 CEST 2013


On 6 Apr 2013, at 4:23 PM, Federico Brega wrote:

> Hello everyone,
> 
> I'd like to do a full screen application for multi-touch devices. It
> splits the screen (window) vertically, each half should track the
> position of a finger touching it.
> I'm using Qt Quick 1 because my only multi-touch device runs Android.

Android support in Qt5 is getting good enough to use now: you just have to build it yourself, build the latest Creator yourself (2.7 branch from git) in order to get the latest android deployment goodies, and you might run into a bug or two along the way.  But then you could use QtQuick 2.1.

http://qt-project.org/wiki/Qt5ForAndroid

> The only way to do this, in my understanding, is exposing multi-touch
> events by subclassing QDeclarativeItem.
> I tried several ways:
> - an item for each half, it simply mimics the behaviour of MouseArea
> - a single item dispaching touch events to the appropriate side
> 
> None of them really worked. The worst scenario is when I start
> touching the left side, then touch also the right side and finally
> release the left side.
> At this point the touch point on the right side isn't tracked anymore.
> 
> My last try appended at the end of this message
> 
> Is this achievable in Qt 4?
> Are the new touch area in Qt5 useful for this purpose?

I tried to create a piano in QML.  One way is to use one MultiPointTouchArea for the whole thing; then you get a list of touchPoints with coordinates, and you have to do some math to figure out which finger is touching what.  For you, this math should be easy since you only have two areas of interest: you can iterate the touchPoints and check the x coordinates.

But you can also use one MultiPointTouchArea per area of interest (per piano key), which sounds redundant since you only expect one touch on each; but the fact is MouseArea only handles mouse events, and since Qt doesn't support multiple mice, there also can't be two MouseAreas "pressed" at the same time.  Whereas MPTA handles the touch events and ignores mouse events, so it's possible to touch multiple MPTA's at the same time.  But I also found a bug, which I haven't fixed yet: if you press two MPTAs simultaneously, they get "stuck" and don't always go back to the released state (at least on Linux/X11).  Hopefully I can get that fixed for 5.1.




More information about the Interest mailing list