I wrote this piece of code, but I get this error:
"left of '->key' must point to class/struct/union/generic type".
Considering that GUI is a class derived from the QWidget
class, how can I properly catch the pressing of a key?
void GUI::keyPressEvent(QKeyEvent *event)
{
if (event->key()==Qt::Key_Up) {
//do something
}
}
The keyPressEvent
is declared like this:
protected:
virtual void keyPressEvent(QKeyEvent *event);