[PyQt] QLineEdit vs. menu keyboard shortcuts

Baz Walter bazwal at ftml.net
Tue Jun 28 18:48:16 BST 2011

On 28/06/11 16:50, Nathan Weston wrote:
> QLineEdit has some keyboard shortcuts (e.g. Ctrl+Z for Undo) that clash
> with the shortcuts for QActions in my application menus. When a
> QLineEdit has keyboard focus, it intercepts these shortcuts and my
> QActions are never triggered.
> I'd like to give application-level shortcuts precedence over QLineEdit's
> shortcuts, but I can't seem to find a clean and general way to do this.
> Alternatively, is there a way to customize the keyboard shortcuts in
> QLineEdit? If I could disable some of the problematic shortcuts that
> would be a reasonable workaround.

the default key bindings for QLineEdit are hard-coded, but the actual 
key sequences used are platform-dependent (and the same goes for most 
(all?) other widgets which have them).

but what is your reason for wanting to change the default behaviour?

as a user, i would expect all the 'normal' shortcuts to work when typing 
in a line edit. if Ctrl+Z undid something in some other widget that i 
wasn't looking at, it could become very confusing. (IIRC this was how 
things used to work with qt3 - and good riddance to that!).

More information about the PyQt mailing list