[Development] QKeySequenceEdit questions

Volker Hilsheimer volker.hilsheimer at qt.io
Mon May 16 15:57:41 CEST 2022



> On 11 May 2022, at 16:02, Laszlo Papp <lpapp at kde.org> wrote:
> 
> Hi,
> 
> 1. I would like QKeySequenceEdit to block the processing of hotkeys while recording, so that the new hotkey being recorded is not getting handled (e.g. cmd+q does not close the Qt app in this mode).
>  
> Is this already possible to achieve? I think that modal dialogs work ok for example. But in my case, I am not using a model dialog.
> 
> Here is a testbed where you can reproduce the issue: https://github.com/lpapp/examples/tree/main/qt-hotkey-editor
> 

Hi Laszlo,


I’ll have to look a bit more, but looking at the code I see that QKeySequenceEdit accepts both the ShortcutOverride and the Shortcut event, so it should take precedence over any application-defined shortcut. If/since that doesn’t work, 

But since you write cmd+q (and considering your recent patches) I think that perhaps you are on macOS, and it might be that our macOS shortcut code doesn't respect the focus widget’s override for application level shortcuts.

Bottom line anyway: this should already work, so if it doesn’t, I’d consider that a bug.


> 2. Is it possible to configure QKeySequenceEdit not to support multiple keypresses as a shortcut for an action? It seems to be the default behaviour and it feels a bit odd at first. At least, not how we would like to use this. I am referring to the "A, B, C" setup that is possible. If not, is this something that should be configurable?


Making it possible to configure the max length of the recorded QKeySequence could be a useful feature addition. I don’t see that this is possible today, but implementing it might not require much more than replacing the use of QKeySequencePrivate::MaxKeyCount with a property.

Volker



More information about the Development mailing list