[Qt-interest] How install shortcuts for multiple widgets?

Frederic Tingaud tingaud at gostai.com
Wed Feb 9 11:11:08 CET 2011


  Le 08/02/2011 22:06, Wilhelm a écrit :
> Hi all,
>
> what is the "right" way to install shortcuts (say Ctrl-S) without
> getting the "... ambiguous shortcut ..." error?
>
> If I have an application menu with an action using shortcut Ctrl-S and
> e.g. several other widgets which also install this shortcut I get the
> above error.
>
> So the question is, how to setup up an applications-wide shortcut Ctrl-S
> that saves a file A if triggered in a texteditor widget A if that has
> focus, or saves a file B if triggered in a texteditor widget B if that
> has focus?
>
> I tried using the shortcut-context and setting it to WidgetContext but
> without luck.
>
> Any hints?
>

I had the same question and after looking at existing code and 
struggling without success with shortcuts context, I decided to stop 
using shortcuts for these kind of cases and using QKeyEvent on the 
different widgets. I lose the display of shortcuts in menus, but apart 
from this, it works perfectly well.

-- 
-------------------------------------------------------------------------------
Frederic TINGAUD
-------------------------------------------------------------------------------




More information about the Qt-interest-old mailing list