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. Keyboard shortcuts - detecting key press and release
Forum Updated to NodeBB v4.3 + New Features

Keyboard shortcuts - detecting key press and release

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.2k 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.
  • X Offline
    X Offline
    x6herbius
    wrote on last edited by
    #1

    I'm wondering whether it's possible to use Qt's keyboard shortcut facilities (either QShortcut or QAction) to fire events depending on the up/down state of keys? I have a camera view where the 3D camera is controlled by the WASD keys and I'd much rather have the user be able to to set the key bindings in the same window as they would adjust the rest of the application keyboard shortcuts, rather than having to hard-code things or deal with QKeyEvents in the view widget manually.

    I have experimented with checkable QActions and these are almost what I want - if I add an action to a QWidget, the triggered(bool state) signal can be connected to a stateful(bool state) slot or a stateless() slot, depending on the type of shortcut I want (true/false vs. one-off). However, the checked state of the QAction is changed only when I re-press the keyboard shortcut, which isn't great for controlling camera movement. Is there any possible way to utilise this setup where the state bool of the signal reacts to the up/down state of the key combination?

    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