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. QKeyEvent and last release event

QKeyEvent and last release event

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k 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.
  • _ Offline
    _ Offline
    _Mark_
    wrote on last edited by
    #1

    I reimplemented the following functions:

    @
    void keyPressEvent(QKeyEvent *);
    void keyReleaseEvent(QKeyEvent *);
    @

    in order to catch when the user press or release some keys.
    I'm interested only to the first press event and to the last release one.

    The former is straightforward: it's enough to check the isAutoRepeat value. I don't know how to catch the last release event instead.
    My only idea is to use a QTimer to detect a timeout in the autorepeat... but it's not very handy because each user may have different repetition timing.

    I just want to intercept when the user physically raises the key. How to?

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

      Hi, AFSIK, isAutoRepeat works for keyRelease too.

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        _Mark_
        wrote on last edited by
        #3

        Yes, but it's not useful. I've just tried again: press and hold a key, then release it. Here the output;

        @
        // press and hold the key
        pressEvent, isAutoRepeat = false
        releaseEvent, isAutoRepeat = false
        pressEvent, isAutoRepeat = true
        releaseEvent, isAutoRepeat = true
        pressEvent, isAutoRepeat = true
        releaseEvent, isAutoRepeat = true
        pressEvent, isAutoRepeat = true
        releaseEvent, isAutoRepeat = true
        .
        .
        .
        @

        Yes, it tells me the release event is generated by an "auto repetition" of the key. But I have no information about the last event. I mean the last event after the user has really released the key.

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

          In Qt5.1/Windows XP, the result is:

          @
          // press and hold the key
          pressEvent, isAutoRepeat = false
          releaseEvent, isAutoRepeat = true
          pressEvent, isAutoRepeat = true
          releaseEvent, isAutoRepeat = true
          pressEvent, isAutoRepeat = true
          releaseEvent, isAutoRepeat = true
          pressEvent, isAutoRepeat = true
          releaseEvent, isAutoRepeat = false
          @

          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