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. KeyReleaseEvent() not picked up after opening file chooser with shortcut Ctrl+O
Qt 6.11 is out! See what's new in the release blog

KeyReleaseEvent() not picked up after opening file chooser with shortcut Ctrl+O

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k 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.
  • J Offline
    J Offline
    jesuisbenjamin
    wrote on last edited by
    #1

    Hello,

    I have implemented a Ctrl+wheelEvent for a zoom action on a QGraphicsView. I manage this by picking up the keyPressEvent(), set a self.ctrl = True value and on keyReleaseEvent() I set the self.ctrl = False.

    It works correctly except when I open the file chooser with Ctrl+O, in which case the keyPressEvent() is picked up, but the keyReleaseEvent() is not. Because of this the self.ctrl remains True and a wheelEvent alone is then able to activate the zoom action without the Ctrl key being pressed.

    I work around this by setting the self.ctrl value to False right after the file chooser has done its job, but I find this an ugly way to solve the issue.

    So did I implement this the wrong way? What's the best practice? Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mkuettler
      wrote on last edited by
      #2

      Hi Benjamin :)

      You can use
      @
      if (event->modifiers() & Qt::ShiftModifier) {
      // Shift is pressed
      }
      @

      in your wheelEvent.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkuettler
        wrote on last edited by
        #3

        Oh, you would obviously want to use
        @
        event->modifiers() & Qt::ControlModifier
        @

        Sorry.

        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