Important: Please read the Qt Code of Conduct -

How to get only the last system event from a specific type ?

  • Hi,

    If an application only refresh once per second, it will only get one mouse event (QMouseEvent), the last one, and not every 60 moves I could have done while the application was busy.

    How can I get the same behaviour with QTabletEvent ? If I move the pencil a tiny bit I get hundred messages in a sec, and my app can only work with 20 at max per second. So after a second it ends up computing a huge QTabletEvent queue that is several seconds old, and it get worse every second I move the pencil.
    How can I get only the last relevant event ?


  • You can store time of previous event handling and skip events if currentTime-handlingTime < delta, where delta is some value (I think something like 500ms will be good).

  • Yeah I've done something like that by adding the following code in tabletEvent():
    @ static QTime lasteventtimer;

    But it loose a lot of meaningful tablet events, the handling becomes very choppy.

    Maybe there's a way to see if they are other QTabletEvent pending in the queue ?

  • Maybe you can optimize your event handling? I think that it will also help. I'm not sure knowing of more events pending will help you (and afaik it is impossible to get this info)

  • I think I have found some kind of workaround: if I ignore() QEvent::TabletMove events, they get transformed into mouse event, so I only have significant mouseevent instead.

Log in to reply