I tried with an event filter for focus on the openGL widget but it didn't work,
Show your code.
You can also subclass QGLWidget and overload the corresponding event handlers.
But and event filter should work as well.