⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Guide - Qt 5 + OpenGL

  • *Hello everyone!

    I need to develop a new application using Qt and OpenGL to render some 3D geometrys.
    I downloaded the lastest version of these softwares in the "Downloads" section of this website. The file name is Qt 5.2.1 for Windows 64-bit (VS 2012, OpenGL, 553 MB), and I am using the Visual Studio Add-in 1.2.2 for Qt5 too, because I'm using VS2012.

    Googling for tutorials in the internet and in the YouTube, a found a lot these. But almost ever using the QGLWidget class, wich belongs to QtOpenGl module. But now, the Qt website recommends to use the QtGui library instead off this module. So, my questions:

    1 - Is there a way to use the QtGui library (OpenGL) with QtDesigner? I couldn't find a way to do that. If positive, could you show me a tutorial or exemple?

    2 - Could you show another guide, tutorial or exemple to learn how to use the QtGui library to work with OpenGL? This website only shows one exemple and the Dr. Sean Harmer Video didn't help me. Using QtGui instead of OpenGL add-in, is a new approach (I think), and there are few exemples in the internet.

    Thanks for the help.

  • You can place QGLWidget into a Designer layout by placing a QWidget and using the "Promote To..." functionality to promote it to your QGLWidget subclass. The content of the GL widget is provided by your subclass paintGL() function.

    See the examples, particularly the Hello GL Example, here:

  • Thank you for your reply!

    But is there a way to use QtGui library and QGLWidget together? Could you show me some exemples?

  • Hi, what do you mean with QtGUI lib? the GUI lib in Qt 5 is just the windowing stuff and OpenGl integration etc and without it you can't display anything so of course you can just integrate that with OpenGL.

    If you mean Qt widgets lib, that works like always you can use widgets the same way in layout and the QGLWidget can be used to draw custom OpenGL code. If you want to use widgets on top of your QGLWidget that might be a little tricky, but maybe you elaborate your question a little first.

  • Maybe the way I talked was not right.

    Resuming, could you show me some exemples using the QOpenGL classes in Qt GUI (just like this exemple: http://qt-project.org/doc/qt-5/qtgui-openglwindow-example.html) intead of exemples using the QtOpenGL Add-in (not recommended anymore)?

Log in to reply