   Qt Help..
  Im fairly new with Qt and it has been working out fine I'm just a little stuck. I'm using it for all the other stuff so i can concentrate on the OpenGL and the other stuff of making a game. The part where I'm stuck is when i try to get or set when a key is pressed so i can move my character. I got that i would have to use void keyPressEvent( QKeyEvent * event );in my QGLWidget class. So I think. Which I tried but it does not pick up the key being pressed, so my character does not move.Any suggestions would be greatly appreciated.   
  Does your class get compiled by the meta object compiler? You need to have a Q_OBJECT entry in your class definition before any of the signals/slots will be processed :class MyClass : public QGLWidget{ Q_OBJECT  public :   ... void keyPressEvent( QKeyEvent* event )};  Yeah i have the Q_OBJECT, everything else works fine. I did not have that function under public i had it under protected, let me change it. thanks;  no, it still didnt move :(   ;Quote:Original post by MadMex_Mno, it still didnt move :(Is the keyPressEvent function ever being called? Post some code (the header file at least) otherwise it's kind of hard to debug :)   ;  this is the my header:#ifndef GLWIDGET_H#define GLWIDGET_H#include <QGLWidget>class GLWidget : public QGLWidget{ Q_OBJECTpublic: GLWidget(QWidget *parent = 0); void keyPressEvent(QKeyEvent *event); ~GLWidget();protected: void initializeGL(); void paintGL(); void resizeGL(int width, int height); private:GLuint makeObject();void makePlayer();float playerX;float playerY; GLuint object;};#endifand the declaration of keyPressEvent:void GLWidget::keyPressEvent(QKeyEvent *event){switch (event->key()){case Qt::Key_Left:playerX -= 0.5;break;default: QGLWidget::keyPressEvent(event);}}the code looks wierd here, as in everthing is align to the left when i post it;  hmmm, that class definition looks like it should be OK although I would move the keyPressEvent function definition back in to the protected section.Just reading through the QT notes :Quote:A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.If you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.Make sure you are calling setFocusPolicy(), probably in the GLWidget constructor.   ;  I think that means when you have an actual button as a widget, because the parameters for that function are as if to set focus to the button by tabbing to it or by clicking on it so i have to use one of those.   ;  try putting setFocusPolicy( Qt::StrongFocus )in your GLWidget class constructor.   ;  i changed it nothing happens.   