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. MousePressEvent - space pressed/hold/check?
Qt 6.11 is out! See what's new in the release blog

MousePressEvent - space pressed/hold/check?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 919 Views
  • 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
    Dariusz
    wrote on last edited by
    #1

    Hey

    I'm in mousePressEvent. I can get button/s () to determine what mouse button got pressed and I can use QGuiApplication::keyboardModifiers(); to get what modifier got pressed, but how can I check if space was pressed? I mean I want to know if some one is holding space while pressing mouse button.

    JonBJ 1 Reply Last reply
    0
    • D Dariusz

      Hey

      I'm in mousePressEvent. I can get button/s () to determine what mouse button got pressed and I can use QGuiApplication::keyboardModifiers(); to get what modifier got pressed, but how can I check if space was pressed? I mean I want to know if some one is holding space while pressing mouse button.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Dariusz
      Since there does not appear to be a Qt function to tell you if a (non-modifier) key is being pressed, you can use the generic key pressed & released events to track the spacebar down/up for yourself, and use the result in your mouse press event.

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

        Hey

        Ended up installing custom event filter which had event filter that emmited a signal when it was pressed/released. Had to do it this wa as I had to install event filter on both graphicsView and Viewport()

        For any1 interested, the installed class was a QObject with eventFIlter replaced with my signal that send info out when key was pressed. This way if I have mouse move event in action and I press/release key I get proper updates on the go.

        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