[PyQt] Strange KeyPressEvent behaviour

Albert Cervera i Areny albert at nan-tic.com
Sat May 29 20:12:57 BST 2010


I've got a strange behaviour with some keypress events which I've been able to 
workaround but I'd like to share in case it may be a bug in PyQt.

The situation is a bit complex: I execute a PyQt application using an xrdp (an 
open source RDP implementation) server which is being accessed through a 
Remote Desktop Client from a Windows Mobile in a handheld. The Handheld has a 
barcode reader attached which emulates keyboard strokes.

The thing is I can use the barcode reader without problems using the Remote 
Desktop Client against xrdp and with kwrite opened in it. All barcodes are 
written correctly. But when I use my own PyQt application some barcodes are 
not input correctly. For example, code "00121/1" appears in a QLineEdit (and 
QTextEdit too) as "00112/1".

Printing events as they arrive using an event filter shows that the events for 
this string come like this: press 0, release 0, press 0, release 0, press 1, 
release 1, press 1, press 2, release 2, release 1, press /, release /, press 
1, release 1.

As you can see, the strange thing is this part "press 1, press 2, release 2, 
release 1". I've worked arround the problem by 'eating' all press events and 
sending them only when release event arrives for that key because the order of 
release events is correct (00121/1) but not the order of press events 
(00112/1).

Does anyone have an explanation for this? Any chance PyQt may not be sending 
events in the correct order? Note that this does not happen with all barcodes, 
but if a barcode has problems it is *always* printed wrong. Note that I'm 
pointing to PyQt because kwrite, which uses Qt too, works correctly with the 
same setup.

-- 
Albert Cervera i Areny
http://www.NaN-tic.com
OpenERP Partner
Mòbil: +34 669 40 40 18
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100529/ad10a451/attachment-0001.html>


More information about the PyQt mailing list