Hi to all,
I would know how to correctly write an event handler for example a keyPressEvent.

I wrote this event that I would catch when I press the space key:

Qt Code:
  1. void WaveWidget::keyPressEvent( QKeyEvent* pe )
  2. {
  3. switch( pe->key() )
  4. {
  5. case Qt::Key_Space:
  6. {
  7. pe->accept();
  8. qDebug() << "Space pressed";
  9. m_wave->playSound();
  10. }
  11. break;
  12.  
  13. default:
  14. pe->ignore();
  15. break;
  16. }
  17. QWidget::keyPressEvent(pe);
  18. }
To copy to clipboard, switch view to plain text mode 

This is the correct way to write it? Must I accept the event with the right key and ignore in other case? And must I pass the event to the base class?

I don't know why in my case in doesn't work.

Best