QT docs say that since qt5 you should use the QOpenGL* classes instead of QGL*.
Problem is there is no QGLWidget replacement. I figured out that instead you should
QT 5.1 is in a weird situation OpenGL and QWidget
(and derived) wise. There's no QGLWidget
replacement yet all other QGL classes have clear replacements.
If you don't want to use the old QGLWidget
you indeed have to manufacture yourself a replacement with QWindow
. So, first you set up your QWindow
then, as you correctly said call setSurfaceType( OpenGLSurface );
before you call create();
on it. Then you create a new QOpenGLContext
and use its makeCurrent()
function and pass your QWindow
. Then you create a QWidget
from the QWindow
using QWidget::createWindowContainer(window);
But this is only a temporary hack, that you shouldn't have to use unless you actually want to mix QtQuick an QWidget. You can then replace this temporary hack with the actual replacement in 5.2.0 5.4.0 called QOpenGLWidget