[PyQt] QLineEdit vs. menu keyboard shortcuts
Baz Walter
bazwal at ftml.net
Wed Jun 29 18:32:39 BST 2011
On 29/06/11 18:21, Nathan Weston wrote:
> On 6/29/2011 1:07 PM, Baz Walter wrote:
>> as was suggested earlier in this thread, if the line-edit doesn't have
>> the keyboard focus, it can't trigger its own shortcuts. if it *does*
>> have the focus, but the shortcut sequence is not one it handles, the
>> keypress event will be re-propagated (as happens with 'Ctrl+R' in your
>> example).
>>
>> the simplest way to control the focus is to use clearFocus() and
>> setFocus().
please reply to the list so that everyone can read your comments.
> Unfortunately, I need the line-edit to have keyboard focus (and respond
> to some keyboard shortcuts), without bashing my global menu shortcuts.
> It seems like there *should* be a clean way to do this by mucking around
> with the keyPressEvent, but so far nobody seems to know of one.
did you actually try what was suggested?
going back to your earlier example of dragging in the line-edit to
change its value: all you need to do is clearFocus() when the drag
starts and setFocus() when the drag ends. that way, whilst the drag is
in progress, the line-edit's shortcuts won't work, but your global
shortcuts will.
if that's not what you want, please try to make it clear what you do
want (i.e. with a working example).
HTH
More information about the PyQt
mailing list