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.3k 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.
  • C Offline
    C Offline
    cerr
    wrote on 12 Oct 2016, 04:15 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!

    R 1 Reply Last reply 12 Oct 2016, 06:03
    0
    • R Offline
      R Offline
      Ratzz
      wrote on 12 Oct 2016, 04:38 last edited by Ratzz 10 Dec 2016, 04:40
      #2

      @cerr
      How you tried this ?

      --Alles ist gut.

      1 Reply Last reply
      0
      • C cerr
        12 Oct 2016, 04:15

        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!

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 12 Oct 2016, 06:03 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

        C 1 Reply Last reply 14 Oct 2016, 03:10
        2
        • R raven-worx
          12 Oct 2016, 06:03

          @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.

          C Offline
          C Offline
          cerr
          wrote on 14 Oct 2016, 03:10 last edited by
          #4

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

          1 Reply Last reply
          0

          4/4

          14 Oct 2016, 03:10

          • Login

          • Login or register to search.
          4 out of 4
          • First post
            4/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved