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. Sending key shortcuts to active window
Forum Updated to NodeBB v4.3 + New Features

Sending key shortcuts to active window

Scheduled Pinned Locked Moved Unsolved General and Desktop
eventshortcut
5 Posts 2 Posters 2.6k 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.
  • P Offline
    P Offline
    Peppy
    wrote on 24 Jul 2016, 15:06 last edited by
    #1

    Hello guys, I do wonder, what's the best way to send shortcuts to active window? I do have menuBar which emits slots in my "shortcut dispatcher" object. Now I do wonder, how to push forward those messages forward? Hook up focusEvent and cast QWidget to my own Window subclass?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 24 Jul 2016, 21:33 last edited by
      #2

      Why do you "dispatch shortcuts" yourself? Qt has a built in mechanism for shortcuts and scoping.
      If you have a QShortcut with a certain widget parent or a QAction with shortcut added to that widget and you set the context to Qt::WidgetWithChildrenShortcut it will be scoped properly without you doing anything more.

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Peppy
        wrote on 26 Jul 2016, 11:20 last edited by
        #3

        Well, I'm dispatching between multiple windows, hence no common parent is present...I want to have shortcuts active only for active window.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 26 Jul 2016, 11:31 last edited by
          #4

          I'm not sure I understand. If you have shortcut shA with parent window A and shortcut shB with parent window B and both shortcuts have a Qt::WidgetWithChildrenShortcut scope then they work in their respective windows. The windows don't need a common parent for shortcuts to work.

          1 Reply Last reply
          2
          • P Offline
            P Offline
            Peppy
            wrote on 22 Sept 2016, 18:55 last edited by Peppy
            #5

            Well, I have a custom shortcut shC applied to Action/Menu which is global (in every window), but I can not register that into window A, or window B. I mean, I am on OS X, where there is only one menubar that is shared across the multiple windows, so I have to dispatch them, right?

            I mean, for example, Qt Creator has a shortcut "Run" which is invokable from many windows. But I can not make two menubars and/or having two actions, right?

            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