View Full Version : QOpenGLWidget: do I need this?

20th April 2014, 21:08
I need to add some 3D visualisation to an existing application. It uses a QGraphicsView to display 2D graphics at the moment... Nothing too complicated, but I wanted to make it possible for users to be able to move things around, so QGraphicsView seemed the way to go.

So I'm venturing into OpenGL for the first time for the 3D. I've read about Qt changing the way it provides access to OpenGL significantly in Qt5, and I'd like to save myself some pain down the line.

Currently there's no QtGUI equivalent to QOpenGLWidget. It looks like it's probably coming in Qt 5.4 (I guess?). So if I want touse OpenGL in a QGraphicsView with Qt 5.2, am I stuck with the QOpenGl classes (QGLWidget in particular)? Or is there something I should be doing, like using QWidget::createWindowContainer on some widget that I then use as a viewport? Or is there a better way to future proof my software?

Relevant details: I'm not using Qt Quick. My software needs to run on Windows, but it also runs on Mac and Linux, so if I only implement the 3D stuff in the not-Windows versions until Qt 5.4 is released, I'm ok with that.

20th April 2014, 21:53
Since you currently have a QWidget based application you could be using QGLWidget for the 3D scene and keep any normal user interface elements.

If you want to do only GL without any interface elements, then you could be using QQuickWindow as a base.
If your application does have user interface elements other than the 3D scene then a QQuickView might be handy.