keyPressEvent() is not catching some keys on OSX
I am writing a program in Qt c++ and I'm having some problem handling key press events. When run on Linux (Ubuntu 10.10) or Windows 7 the application catches these key events just fine. However when I run the program on OSX 10.6.7 it doesn't catch any character keys, number keys, or the arrow开发者_开发问答 keys. It does catch the caps lock, command, option, control, shift (modifier keys), but nothing else.
Is there some kind of special case of OSX that I need to handle? Perhaps a configuration? or a signal i need to connect with?
TIA
You need to set the window's focus policy to get it to accept keys.
Something like this:
QMainWindow.setFocusPolicy ( Qt::StrongFocus );
精彩评论