Qt World Summit: Submit your Presentation

Implementation of TouchArea using TUIO API for QML application

  • Hello,
    For one of my project We implemented a QML plugin not to be dependent to QT evolutions on multitouch Touchareas.
    It works perfectely using Windows event. But we need to be abble to touch 2 separated touch screens simultaneously.
    We found the TUIO implementation, and I started adding the code into my plugin. It works but we have to manage every thing inside :

    • ToucheArea overlaping / Depth
    • toucheArea coordinate computations
    • TUIO send the globale normalised position of the touch point in the whole windows desktop
      My class is defined like this:
      @class QDeclarativeTouchArea : public QDeclarativeItem , TUIO::TuioListener

    I have several questions:

    • In My QML Application I have a List of QDeclarativeTouchArea, How to sort them from the one at the top to the one at the bottom? Since in QML the z property AND the instanciation order defined both the depth of hte instance?
    • How to get the coordinates of the touche Area in the global windwos desktop?

    Here is a simplified illustration of the situation:
    (TUIO Illustration)!

  • Hello I manage to go forward I try to generat an QtouchEvent, and to post it to the QApplication, in order to use the native QT filtering:
    @bool QDeclarativeTouchArea::event(QEvent *event)@
    @bool QDeclarativeTouchArea::sceneEventFilter(QGraphicsItem *i, QEvent *event)@

    The problem is:

    • the coordinate of the point coming from TUIO is correct
    • the event is send
    • But none of my touch areas received the events!!
    • The native windows touch events are received properly!

    Here after is the code for the TUIO to QT event mapping function.
    @bool QDeclarativeTouchArea::tuioToQtEvent(TUIO::TuioCursor *tcur, QEvent::Type eventType)
    //Create Event structure
    QTouchEvent event(eventType);
    QListQTouchEvent::TouchPoint touchPoints = event.touchPoints();
    QTouchEvent::TouchPoint p;

    //Get Normalized globale position
    QPointF lp;
    int id = tcur->getCursorID();
    //Set Values
    switch (eventType) {
        case QEvent::TouchBegin:
            p.setState(Qt::TouchPointPressed );
        case QEvent::TouchUpdate:
        case QEvent::TouchEnd:
            p.setState(Qt::TouchPointReleased );
            //touchPoints. Update Existing
    //copy data into event structure
    //Send Event to main application
    qDebug()<< "QDeclarativeTouchArea::tuioToQtEvent"<< "QApplication::sendEvent(QApplication::instance(), &event)";
    QApplication::sendEvent(QApplication::instance(), &event);
    return true;


Log in to reply