Results 1 to 7 of 7

Thread: Disable automatic event translation

  1. #1
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Disable automatic event translation

    Hey,

    from the doc of QTouchEvent read this:

    Event Delivery and Propagation
    By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not normally handle QTouchEvent. See below for information on some special considerations needed when doing this.
    Has anyone an idea, how to disable the default behaviour of translating the fist non-primary touch point into a mouse event?

    Further the docs explains:
    Mouse Events and the Primary Touch Point

    QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse events are also sent for the primary touch point. This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to identify the primary touch point.
    How to interpret
    On some windowing systems, mouse events are also sent for the primary touch point.
    How can i identify the way my OS(Win7) handles this?

    Anyone any ideas on this?

    Thanks for help

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Disable automatic event translation

    Quote Originally Posted by kinglui987 View Post
    Has anyone an idea, how to disable the default behaviour of translating the fist non-primary touch point into a mouse event?
    Reimplement QWidget::event() and if you detect a first touch event, don't call the default implementation but rather do something that suits your goals.

    How can i identify the way my OS(Win7) handles this?
    Make a test application and see for yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable automatic event translation

    Hey thanks for your help. Sorry for my late answer but unfortenately i did not get a notification from the forum.

    I am still confronted with some problems.

    I am attempting to hook an application and listen for touch an mouse events, simultaneously. I have a device that supports this. I am cathcing the events generated from my device, convert them to QEvents and post them in QT event loop using the postEvent(...) mechanism of QCoreApplication . Now am able to get the events simultaneously, but there still some problems.

    The OS generates the mouse event for me (as usual), i am catching the touch events from my device and post them as described in Qt event loop.

    However, it seems not to work properly, since sometimes two events get generated for the same input source (e.g. mouse or finger)

    What i need is to identify the situation, when the OS generated an mouse event? Then, and only then, i fire my events, when there is touchinput registerd at my device. How would you build such a system?

    Any suggestions, how build a stable architecture to manage this?

    Thanks in advance

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Disable automatic event translation

    Maybe you should install an event filter on the application object? Then all events will go to the filter first before reaching the final object and you'll be able to decide what to do with them.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable automatic event translation

    Hey,

    that is exactly what i am currently doing. Maybe this is already the right way to do this.

    Any other suggestions would be greatly appreciated ;-)

    thanks so far...

  6. #6
    Join Date
    Nov 2012
    Posts
    18
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable automatic event translation

    Hey there,

    it again me. Unfortunately i am again confronted with some problems. It seems that i never will understand QT event processing! I would like to understand, what QT does with the events. I installed an eventfilter on the qApp object. To my understandig, now alle events of all objects in the application go to the eventfilter object, right?

    Imagine the following:
    What if there are some Widgets in the application with setAttribute(Qt::WA_AcceptTouchEvents) called and some without this?
    To my understanding, there will be differences in the event generated and catched by the installed eventfilter, depending on where the event was generated, so it makes it very hard to implement a generic eventhandling? Any suggestions on this?

    Now back to the topic of this thread:

    I simply could not achieve to disable to automatically generated MouseEvent for the first TouchEvent, as described in the docs. In the Examples of QT i modified the scribblearea.cpp in the fingerpaint example.
    I deleted all specific eventhandlers and reimplemented the QWidget::event(QEvent *event) eventhandler.
    Here is the code:

    Qt Code:
    1. bool ScribbleArea::event(QEvent *event)
    2. {
    3. bool handleEvent = false;
    4. QInputEvent* inPut = dynamic_cast<QInputEvent*>(event);
    5. if(inPut)
    6. {
    7. switch (event->type())
    8. {
    9. case QEvent::TouchBegin:
    10. std::cout<<"ScribbleArea received TouchEvent BEGIN";
    11. inPut->accept();
    12. handleEvent=true;
    13. break;
    14. case QEvent::TouchUpdate:
    15. //std::cout<<"ScribbleArea received TouchEvent UPDATE";
    16. inPut->accept();
    17. handleEvent=true;
    18. break;
    19. case QEvent::TouchEnd:
    20. std::cout<<"ScribbleArea received TouchEvent END";
    21. inPut->accept();
    22. handleEvent=true;
    23. break;
    24. case QEvent::MouseButtonPress:
    25. std::cout<<"ScribbleArea received MouseEvent PRESS";
    26. break;
    27. case QEvent::MouseButtonRelease:
    28. std::cout<<"ScribbleArea received MouseEvent RELEASE";
    29. break;
    30. case QEvent::TabletPress:
    31. std::cout<<"ScribbleArea received TabletEvent PRESS";
    32. handleEvent=true;
    33. break;
    34. case QEvent::TabletRelease:
    35. std::cout<<"ScribbleArea received TabletEvent RELEASE";
    36. handleEvent=true;
    37. break;
    38. case QEvent::TabletMove:
    39. //std::cout<<"ScribbleArea received TabletEvent TabletEvent MOVE";
    40. handleEvent=true;
    41. break;
    42. }
    43. return handleEvent;
    44. }
    45. return true;
    46. }
    To copy to clipboard, switch view to plain text mode 

    As the code illustrates i accept all touchevents and return handleEvent=true, which to my understand should mean there will be no further processing/propagation. Note, i do not call the base implementation.
    However, the output is like this:

    Qt Code:
    1. ScribbleArea received TouchEvent BEGIN
    2. ScribbleArea received MouseEvent Press
    3. ScribbleArea received TouchEvent END
    4. ScribbleArea received MouseEvent RELEASE
    To copy to clipboard, switch view to plain text mode 

    Consuming QTabletEvent by returning
    Qt Code:
    1. handleEvent=true
    To copy to clipboard, switch view to plain text mode 
    however works, no MouseEvent gets generated for already handled QTabletEvent?

    Any help on this from you guys would be greatly appreciated

  7. #7
    Join Date
    Oct 2013
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Disable automatic event translation

    Hey experts,

    Is there any solution for this problem for QTouchEvent? I am having the same problem.

    Thanks,
    Sam

Similar Threads

  1. How to disable the automatic selectioning in a QGraphicsscene?
    By maikelmeyers in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2011, 06:11
  2. Disable touch event when using QWebkit
    By chika in forum Qt Programming
    Replies: 1
    Last Post: 28th February 2011, 11:09
  3. Disable uic translation from utf8
    By Vertilka in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2009, 17:47
  4. Automatic translation in qmake's project?
    By mchara in forum Qt Programming
    Replies: 7
    Last Post: 11th July 2008, 15:11
  5. How to disable maximum event in QWidget??
    By hesummar in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2006, 13:21

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
  •  
Qt is a trademark of The Qt Company.