Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get only the last system event from a specific type ?

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    divide
    wrote on last edited by
    #1

    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 ?

    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      • D Offline
        D Offline
        divide
        wrote on last edited by
        #3

        Yeah I've done something like that by adding the following code in tabletEvent():
        @ static QTime lasteventtimer;
        if(lasteventtimer.elapsed()<100)
        return;
        lasteventtimer.restart();@

        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 ?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          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)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            divide
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved