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?
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With