Results 1 to 5 of 5

Thread: how to manually create touch event?

  1. #1
    Join Date
    Sep 2011
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Maemo/MeeGo

    Default how to manually create touch event?

    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?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to manually create touch event?

    yes you are right, you need to use sendEvent() or postEvent().

  3. #3
    Join Date
    Sep 2011
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Maemo/MeeGo

    Default Re: how to manually create touch event?

    hi,
    could you please elaborate, my major concern is what parameters need to passed QEvent subclass object for creating a valid touch event?

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to manually create touch event?

    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.

    Qt Code:
    1. MyWidget::event(QEvent*event)
    2. {
    3. if ( event->type == QEvent::TouchBegin ) //touchEnd etc
    4. {
    5. qDebug() <<event; //will show the paramenters
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to manually create touch event?

    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.

    Qt Code:
    1. class MyEvent: public QObject
    2. {
    3. ...
    4. QEvent myevent;
    5. virtual bool event(QEvent *e);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. MyEvent:MyEvent()
    2. {
    3. // somthing doing with QEvent::registerEventType - but what
    4. // using function "setEvent(HANDLE h)" from my API of the evternal event - but how
    5. }
    6. MyEvent:event(QEvent *e)
    7. {
    8. emit myEventSignal;
    9. }
    To copy to clipboard, switch view to plain text mode 

    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

Similar Threads

  1. touch event
    By leoalvesmachado in forum Newbie
    Replies: 12
    Last Post: 20th February 2014, 09:07
  2. Disable touch event when using QWebkit
    By chika in forum Qt Programming
    Replies: 1
    Last Post: 28th February 2011, 11:09
  3. Replies: 1
    Last Post: 14th February 2011, 04:30
  4. Simulating a touch event without a connected mobile phone
    By Rakula in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 5th October 2010, 06:59
  5. Creating event manually and using them
    By vajindarladdad in forum Newbie
    Replies: 4
    Last Post: 28th August 2009, 08:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.