Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between QGLWidget and QOpenGLWidget?

Tags:

qt

I was reading through some examples on the net to use Qt for rendering stuff with OpenGL and most of then use QGLWidget. However, when I was using Qt Designer I noticed it adds a QOpenGLWidget to the form.

What pros/cons have one over the other?

like image 893
BRabbit27 Avatar asked Jul 20 '15 15:07

BRabbit27


1 Answers

The most important point is that QGLWidget only exists for compatibility reasons to older codebases. As suggested in the Qt documentation on QGLWidget, starting from Qt 5.4 you should use QOpenGLWidget instead.

Generally, the new QOpenGLWidget

retains the familiar initializeGL/resizeGL/paintGL API, while enabling full interoperability with other widgets in complex user interfaces.

as detailed in this blog post. This includes:

  • Offscreen rendering using framebuffer objects instead of a native window. This has performance advantages on mobile platforms.
  • Enhanced support for instantiating explicit OpenGL profiles
  • Context sharing between widgets has been simplified
  • There are subtle differences in the setup of the OpenGL state
  • Direct support for multisampling

In short: If you have the choice, always go for QOpenGLWidget as there is virtually no downside if you do not have to maintain backwards compatibility.

like image 128
Jack White Avatar answered Oct 25 '22 11:10

Jack White