Emplementing QTouchEvent like to emùulate "native Windows Touch Events"
-
Hello,
I would like to emit an QTouchevent like a windows Touch event The idea is to emulate touchpoints for a QML application. So I am not sure:- what type of event I shoud send (maybe is is not a QTouchEvent)
- How I should send it
- what is the target
So far I am building a QTouchEvent, I filled the touchpoint list with one point, and post it to the QApplication. But it crashes. In the debugger the callstack become unusable after being in "QtGui4.dll!QGestureEvent::isAccepted()"
I tried using "QApplication::sendEvent(QApplication::instance(), &event);", it does not crash but the event is not dispatched to the touchAreas.
I will appreciate some advices. Hereafter is the code I wrote to create and send the event.
Thancks a lot.@ //Create Event structure
QTouchEvent event(eventType);
QListQTouchEvent::TouchPoint touchPoints = event.touchPoints();
QTouchEvent::TouchPoint p;//Set Normalized globale position (0;1) QPointF lp; lp.setX(tcur->getPosition().getX()); lp.setY(tcur->getPosition().getY()); //Set Touch ID 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 QApplication::postEvent(QApplication::instance(), &event);
@
-
Hi I FInally get somethingworking but there is still a BUG.
Here is what I do when I receive TUIO events, in my Application viewer (class ApplicationViewer
: public QDeclarativeView)- I build aQListQTouchEvent::TouchPoint
- Ifill it with QTouchEvent::TouchPoint
- I call diredtely:
@QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
qAppPriv->translateRawTouchEvent(this,QTouchEvent::TouchScreen,touchPointsList);@
on the test QML interface I made using touch areas it start working, but if I move "to much" a touch point (QEvent::TouchUpdate:) or if I touch 2 different touchareas simultaneously I have an
- [Qt fatal] ASSERT: "cachedItemsUnderMouse.first() == origin" in file graphicsview\qgraphicsscene.cpp, line 5946*
Does someone has a advice?
Here is the code where the assertion: occured
@bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent)
{
Q_Q(QGraphicsScene);if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) { const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), firstTouchPoint.scenePos(), touchEvent->widget()); } Q_ASSERT(cachedItemsUnderMouse.first() == origin);@