Sending key shortcuts to active window
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?
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::WidgetWithChildrenShortcutit will be scoped properly without you doing anything more.
Well, I'm dispatching between multiple windows, hence no common parent is present...I want to have shortcuts active only for active window.
I'm not sure I understand. If you have shortcut
shAwith parent window
shBwith parent window
Band both shortcuts have a
Qt::WidgetWithChildrenShortcutscope then they work in their respective windows. The windows don't need a common parent for shortcuts to work.
Well, I have a custom shortcut
shCapplied 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?