[Qt-interest] Problem with enter pressed event

Duane duane.hebert at group-upc.com
Fri Mar 25 20:19:41 CET 2011


using Qt 4.7.1 LGPL on Windows.

I have a dialog with a QLineEdit and some QPushButtons.  I'm setting the 
edit box to accept a scanner input and using the enter pressed event to 
detect when the entry is made.

This works fine when testing with a keyboard (and presumably with the 
scanner) but the problem is that when the user enters text in the line 
edit and presses enter, one of the buttons also gets a clicked event.

I can prevent this by setting the focus policy to the line edit to wheel 
focus and all of the buttons to no focus.  But shouldn't the line edit 
gobble the enter pressed event when focus is on the line edit?

Any suggestions?




More information about the Qt-interest-old mailing list