Hi!

I have reimplemented the keyPressEvent to do some stuff. But I can't make it work. The purpose of the key events is to do something and then a GLWidget is supposed to be redrawn to show the result. It works with some keys, but nothing happens when sertain keys are pressed. Or at least nothing is done until I do something else that requires the GLWidget to be redrawn. When that is done, the result is shown.

Here is some code, the F key is the one not working. The A key works just fine, also the Shift and all the rest. Maybe I haven't called setFocusPolicy ( ) correct. I've tried to insert it in the mousPressEvent(), but that didn't do anything.

I tried to print some trace text, but that didn't come out as I hoped. Look in the code...

Qt Code:
  1. void keyPressEvent ( QKeyEvent *event )
  2. {
  3. std::cout<<"this is not always written when a key is pressed..."<<std::endl;
  4. switch ( event->key() )
  5. {
  6. case Qt::Key_Shift:
  7. {
  8. // WORKS FINE
  9. }
  10. break;
  11.  
  12. case Qt::Key_A:
  13. {
  14. // WORKS FINE
  15. // does something ....
  16. update ( ); // updates the GLWidget
  17. }
  18. break;
  19.  
  20. case Qt::Key_F:
  21. {
  22. // THIS KEY DOESN'T WORK!
  23. focusSelection ( );
  24. update ( );
  25. }
  26. break;
  27.  
  28. default:
  29. event->ignore ( );
  30.  
  31. }// switch
  32.  
  33. }// keyPressEvent(QKeyEvent*)
To copy to clipboard, switch view to plain text mode 

thanks for reading
pir