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. How to set custom keysequence for QAction menu element
Forum Updated to NodeBB v4.3 + New Features

How to set custom keysequence for QAction menu element

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 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.
  • cerrC Offline
    cerrC Offline
    cerr
    wrote on last edited by
    #1

    Hi,

    First of,m I'm a newbie!
    I have a menu bar with some actionm points to which I now want to assign a short cut. I've done this already for available shortcuts like quitAct->setShortcuts(QKeySequence::Quit); which worked fine but I now also want to add one with a customized shortcut of Ctrl+;, I'ver tried this: splitHAct->setShortcuts(QKeySequence(tr("Ctrl+;","Ctrl+;"))); but am only getting: error: no matching function for call to ‘QAction::setShortcuts(QKeySequence)’ how can I get my custom shortcut going?
    Thanks!

    raven-worxR 1 Reply Last reply
    0
    • RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by Ratzz
      #2

      @cerr
      How you tried this ?

      --Alles ist gut.

      1 Reply Last reply
      0
      • cerrC cerr

        Hi,

        First of,m I'm a newbie!
        I have a menu bar with some actionm points to which I now want to assign a short cut. I've done this already for available shortcuts like quitAct->setShortcuts(QKeySequence::Quit); which worked fine but I now also want to add one with a customized shortcut of Ctrl+;, I'ver tried this: splitHAct->setShortcuts(QKeySequence(tr("Ctrl+;","Ctrl+;"))); but am only getting: error: no matching function for call to ‘QAction::setShortcuts(QKeySequence)’ how can I get my custom shortcut going?
        Thanks!

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @cerr
        the QAction::setShorcuts() expects a list of QKeySequences. You want to use QAction::setShortcut() which expects a single QKeySequence parameter.
        Note that a single QKeySequence can actually hold up to 4 shortcuts.

        Also note that such shortcuts (using special characters) are problematic on some keyboard layouts. For example on a german layout to get ; i also have to press the SHIFT modifier.

        Edit: you may want to use QKeySequenceEdit widget to check the key sequence for your shortcut.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        cerrC 1 Reply Last reply
        2
        • raven-worxR raven-worx

          @cerr
          the QAction::setShorcuts() expects a list of QKeySequences. You want to use QAction::setShortcut() which expects a single QKeySequence parameter.
          Note that a single QKeySequence can actually hold up to 4 shortcuts.

          Also note that such shortcuts (using special characters) are problematic on some keyboard layouts. For example on a german layout to get ; i also have to press the SHIFT modifier.

          Edit: you may want to use QKeySequenceEdit widget to check the key sequence for your shortcut.

          cerrC Offline
          cerrC Offline
          cerr
          wrote on last edited by
          #4

          @raven-worx Yep, Thanks! That was it: QAction::setShortcut()

          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