PDA

View Full Version : how to manually create touch event?



harshita
9th September 2011, 06:49
hi,
i want to read the touch events from a text file with the required parameters instead of actually using human touch, how can i do that?
What are the parameters that need to be considered to invoke a touch event?
I know that i need to create an instance of QTOuchEvent class and pass QEvent instance as parameter and then call sendEvent, am i thinking in right direction?

Kindly suggest alternative solution?

nish
9th September 2011, 07:35
yes you are right, you need to use sendEvent() or postEvent().

harshita
9th September 2011, 07:38
hi,
could you please elaborate, my major concern is what parameters need to passed QEvent subclass object for creating a valid touch event?

nish
9th September 2011, 07:58
TouchEvent is more complex with lot of parameters. The best way to determine the what type of event parameters are need is to log the real QTouchEvents you get from Qt.

Reimplement the QWidget::event() function and run your application on a real touch screen device and do the touch gesture as you want it to be done, and check for your touchEvents and their parameters, and later you can define your own TouchEvents taking hints from the log.


MyWidget::event(QEvent*event)
{
if ( event->type == QEvent::TouchBegin ) //touchEnd etc
{
qDebug() <<event; //will show the paramenters
}
}

Markus_AC
9th September 2011, 12:10
Maybe my problem is something similar to this problem.

I have a external event (in this case a receive-event from an external device). There is already an application written in MFC which uses CreateEvent and WaitForSingleObject.
I just implemented these functions in my Qt application, but there are 2 problems:

1) I have to do my application for Windows and Linux
2) it seems that WaitForSingleObject sometimes misses events

Should I create a my Class, e.g.



class MyEvent: public QObject
{
...
QEvent myevent;
virtual bool event(QEvent *e);
...
}



MyEvent:MyEvent()
{
// somthing doing with QEvent::registerEventType - but what
// using function "setEvent(HANDLE h)" from my API of the evternal event - but how
}
MyEvent:event(QEvent *e)
{
emit myEventSignal;
}


But I'm not really sure how to manage this.

This was the only Qt-relevant thread for external events I found:
http://developer.qt.nokia.com/forums/viewthread/1529