Key_Space event problem

  • Hi everyone, i'm developing a typing tutor application, on one of my widgets i have a QTextBrowser and some QPushbuttons for the keyboard layout. I implement keyPressEvent such that when a user types the text browser is updated, however when i push the space button one of the QPushbuttons on the keyboard layout is catching the event. I've tried @setFocusPolicy@ but it doesnt seem to work. Help would be much appreciated.

  • You need to put the focus somewhere other than a QPushbutton or pressing space (maybe enter) will trigger it. Normally users would type into a QTextEdit and it would have the focus but you seem to be avoiding that. If you cannot place the focus elsewhere then you should be able to install an event filter on the QPushButtons (either from outside or by subclassing) and block Qt::Key_Space keyboard events for that button.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.