I know, there is more thread about that in this forum. I looked all of them, but still i cant work it.

Vista Business
Qt SDK 2010.05
Qt Creator 2.0.1

I'm just trying to get which key is pressed.

mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include "ui_mainwindow.h"
  5.  
  6. class MainWindow : public QMainWindow, private Ui::MainWindow
  7. {
  8. Q_OBJECT
  9. private:
  10. Ui::MainWindow *gui;
  11.  
  12. public:
  13. explicit MainWindow(QWidget *parent = 0);
  14.  
  15. protected:
  16. bool keypres(QKeyEvent *keyevent);
  17.  
  18. };
  19.  
  20. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 



mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QKeyEvent>
  3. #include <QDebug>
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),gui(new Ui::MainWindow){
  7. gui->setupUi(this);
  8.  
  9. gui->textEdit->installEventFilter(this);
  10.  
  11. }
  12.  
  13. bool MainWindow::keypres(QKeyEvent *keyevent)
  14. {
  15. if (keyevent->key()==Qt::Key_W)
  16. {
  17. qDebug() << "hi";
  18. }
  19. }
To copy to clipboard, switch view to plain text mode 

main.cpp

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

I just want to control keys and key events.
Regards.