Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Implementation of TouchArea using TUIO API for QML application
QtWS25 Last Chance

Implementation of TouchArea using TUIO API for QML application

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sil20
    wrote on last edited by
    #1

    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:
    !http://imageshack.us/a/img197/2268/ppx1.jpg
    (TUIO Illustration)!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sil20
      wrote on last edited by
      #2

      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;
      lp.setX(tcur->getPosition().getX());
      lp.setY(tcur->getPosition().getY());
      
      int id = tcur->getCursorID();
      
      //Set Values
      p.setNormalizedPos(lp);
      p.setId(id);
      
      //p.setPressure(point->pressure);
      //p.setRect(point->area);
      //p.setScreenPos(point->area.center());
      
      switch (eventType) {
          case QEvent::TouchBegin:
          {
              p.setState(Qt::TouchPointPressed );
              touchPoints.append(p);
              break;
          }
          case QEvent::TouchUpdate:
          {
              p.setState(Qt::TouchPointMoved);
              touchPoints.append(p);
              break;
          }
          case QEvent::TouchEnd:
          {
              p.setState(Qt::TouchPointReleased );
              touchPoints.append(p);
              //touchPoints. Update Existing
              break;
          }
          default:
          {
              break;
          }
      }
      
      //copy data into event structure
      event.setTouchPoints(touchPoints);
      
      //Send Event to main application
      qDebug()<< "QDeclarativeTouchArea::tuioToQtEvent"<< "QApplication::sendEvent(QApplication::instance(), &event)";
      QApplication::sendEvent(QApplication::instance(), &event);
      
      return true;
      

      }@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved