View Full Version : QKeyEvent questions

2nd October 2006, 21:36
I have some questions related to key events in QT 3.3. I have a simple application which I am using to test out using and handling key events. It's not working as I expected it would. Here are the details.

The app displays a small image. I have my function to capture key events (QKeyEvent()). As I press a key on the keyboard, the event handler just writes out "I got x" to cout (using myEvent->text()), just so I can see that the keystrokes are being captured. This part works perfectly.

I have a small credit card reader which plugs into the keyboard port on the computer. You swipe the credit card and it sends the magnetic stripe data to the system as if it were typed on a keyboard. This device works fine. If I issue the command "cat >/dev/null" and swipe the card, it will work all day long.

But, if I swipe the card using my test application, things go screwy. First of all, some of the events have more than one character in the text portion. How can a single key event have multiple characters? The other thing is that there are some characters missing from the input. So, with my test program, the data I get is garbled.

Could it have anything to do with the speed of input? The characters from the credit card reader go in to the system at a much faster rate than a human can type. Is this possibly the reason why it doesn't work?

Thanks for any insight.


3rd October 2006, 07:29
QString QKeyEvent::text () const
Returns the Unicode text that this key generated. The text returned migth be empty, which is the case when pressing or releasing modifying keys as Shift, Control, Alt and Meta. In these cases key() will contain a valid value.

Maybe it would be better if you used key() or ascii() instead of text().