Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. To use QKeySequence or an alternative to it
Qt 6.12 LTS is out! See what's new in the release blog

To use QKeySequence or an alternative to it

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.4k 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
    A Former User
    wrote on last edited by
    #1

    I have a current need that I need to be able to construct key sequences as and when a key is pressed (that includes the modifier). Currently QKeySequence does not handle my requirement but am using it such that its being constructed everytime a key is pressed or released. Also another thing that I noticed is that when only the modifiers are pressed (which is a valid case in my requirement), I should be able to generate a valid QKeySequence, however it does not until there is a non-modifier key (anything other than Ctrl/Shift/Alt/Meta).
    Also it would be ideal to say have QKeySequence::addKey(key) [that will add a key to the current sequence] and QKeySequence::removeKey(key) [that would remove an existing key from the key sequence] to extend it.

    It would be great if anyone could let me know to get this work with QKeySequence or an alternative.

    Thanks.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      or in other words, I need a simple key container which can be used straight in mapping to actions (not QAction, just a function call maybe)

      @if (seq1) do this
      else if (seq2) do that
      ...
      @

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        maybe reimplementing
        "keyPressEvent":http://doc-snapshot.qt-project.org/4.8/qwidget.html#keyPressEvent

        will help you...

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          yup, already re-implmented keyPressEvent, still needed a simpler container to map the key sequence (order does not really matter).

          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
          • Unsolved