I have a aplication with a main window. Pressing a button from the toolbar opens a QGLWidget window that displays a timer animation. I want to kill the timer when the window stops from being active, for example when the user clicks the main window or another program, or even if he minimazes the window. So whats the event I should use ?

I use focusOutEvent, but the animation keeps on runing. Also can I kill the event twice, or this can cause a error ?

My code:

Qt Code:
  1. void GLGraph3D::focusOutEvent(QFocusEvent * event)
  2. {
  3.  
  4. // event->WindowDeactivate
  5. if (event->ActivationChange)
  6.  
  7. if (TimerRotate != 0)
  8. {
  9. killTimer(TimerRotate);
  10. TimerRotate = 0;
  11. }
  12. }
To copy to clipboard, switch view to plain text mode