[Android-development] QLineEdit and virtual keyboard

Eskil Abrahamsen Blomfeldt eskil.abrahamsen-blomfeldt at digia.com
Thu Jul 31 08:45:54 CEST 2014


On 07/24/2014 12:03 PM, maitai at virtual-winds.org wrote:
>
> Ok then, but this is weird to me. As a user I do not expect the 
> virtual keyboard's OK button to close the dialog, but just to close 
> the virtual keyboard so I can continue with other fields.
>
> I have tried to setDefault(false) all the buttons in the dialog but it 
> still calls done(), so it seems I cannot modify this behavior.
>
> Note that pressing the physical "ok" button on the device just close 
> the virtual keyboard and not the dialog.
>
> Well... It seems I have to get used to it ;)
>

This is indeed a bit strange. What's happening here is that the virtual 
keyboard's OK button is generating a key event for the Enter key which 
is sent to the QLineEdit, but since QLineEdit ignores this key, it is 
sent to the QDialog instead. QDialog handles key events and will accept 
its button box when it sees an Enter key. In the case of a virtual 
keyboard, which works on a particular line edit, this is unexpected, so 
I wouldn't mind it if you reported this as a bug, since it should really 
be part of the platform theme (on Windows, enter should accept the 
dialog, whereas on Android this does not make sense).

As a work-around, you can add an event filter to the QLineEdit and 
filter out the Enter key presses by returning true whenever you see them.

-- Eskil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20140731/a2d8fa35/attachment.html>


More information about the Android-development mailing list