[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Strange KeyPressEvent behaviour
From:       Albert Cervera i Areny <albert () nan-tic ! com>
Date:       2010-05-29 19:12:57
Message-ID: 201005292112.57635.albert () nan-tic ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" \
content="1" /><style type="text/css"> p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'DejaVu Sans'; font-size:12pt; \
font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">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.</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">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.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">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 &quot;00121/1&quot; appears in a \
QLineEdit (and QTextEdit too) as &quot;00112/1&quot;.</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">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.</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">As you can see, the strange \
thing is this part &quot;press 1, press 2, release 2, release 1&quot;. 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).</p> <p style="-qt-paragraph-type:empty; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">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.</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br />-- </p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">Albert Cervera i Areny</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a \
href="http://www.NaN-tic.com"><span style=" text-decoration: underline; \
color:#0057ae;">http://www.NaN-tic.com</span></a></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><a href="http://www.NaN-tic.com"><span style=" \
text-decoration: underline; color:#0057ae;">OpenERP Partner</span></a></p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Mòbil: +34 669 40 40 \
18</p></body></html>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic