Since QGLWidget cannot be used for OpenGL / ES
Right, we need to clear up some confusion before going further down the road...
It can be. This widget was invented to extend the usual QWidget
interface with OpenGL desktop and embedded support. Please refer to the following example to see yourself it is possible to use this widget for OpenGL ES functionality:
Now, we can come to the point to answer your question. What you should probably reimplement is the following protected method.
void QGLWidget::paintGL() [virtual protected]
This virtual function is called whenever the widget needs to be painted. Reimplement it in a subclass.
While we are at discussing it, please also check the protected initialization method:
void QGLWidget::initializeGL() [virtual protected]
This virtual function is called once before the first call to paintGL() or resizeGL(), and then once whenever the widget has been assigned a new QGLContext. Reimplement it in a subclass.
This function should set up any required OpenGL context rendering flags, defining display lists, etc.
In fact, you could even deal with overlays with this interface as per the following protected methods:
void QGLWidget::paintOverlayGL() [virtual protected]
This virtual function is used in the same manner as paintGL() except that it operates on the widget's overlay context instead of the widget's main context. This means that paintOverlayGL() is called whenever the widget's overlay needs to be painted. Reimplement it in a subclass.
and
void QGLWidget::initializeOverlayGL() [virtual protected]
This virtual function is used in the same manner as initializeGL() except that it operates on the widget's overlay context instead of the widget's main context. This means that initializeOverlayGL() is called once before the first call to paintOverlayGL() or resizeOverlayGL(). Reimplement it in a subclass.
This function should set up any required OpenGL context rendering flags, defining display lists, etc. for the overlay context.