03-06-2012 01:23 PM
Hello,
apparently I am doing something wrong as I can't catch left, right, up and down keys pressed events in my QT app.
Class is derived from QMainWindow
class CMainWindow : public QMainWindow
{
...
void CMainWindow::keyPressEvent(QKeyEvent *event)
{
qDebug()<<event->key();
QMainWindow::keyPressEvent(event);
event->accept();
}
When I press these keys I always have QT::Key_ESC code here. Tested in QT Builder and having the same behaviour. Qt experts please advise.
Thanks,
BGmot.
03-06-2012 04:55 PM
Hi BGmot,
I am afraid I am not much help here as I have not messed around with any key events in Qt c++.
Here is the docs, I am sure you have already been through this though...
http://qt-project.org/doc/qt-4.8/qkeyevent.html
Here is a basic example:
http://programmingexamples.wikidot.com/qt-events#t
I have had input issues with Qt widgets that turned out to be a focus issue, be sure the widget that you want to accept input has focus.
Good Luck!
Jon
03-06-2012 05:00 PM
Hi Jon,
no, it's not a focus related issue as I *am receiving* events it's just event->key() returns Escape code instead of cursor movement keys codes.
Thanks anyway.