Congratulations to our 2022 Qt Champions!

QGLWidget with child widgets

  • Hello,

    I'm currently developing a 3D application with Qt's QGLWidget.

    I'm having trouble getting some widgets drawn over the QGLWidget.

    What I did is:

    • Create a designer QMainWindow form
    • Put a QWidget as central widget
    • Add child widgets to the QWidget, so they are drawn above
    • Promote the QWidget to my own QGLWidget subclass

    But this leads to child widgets's backgrounds to not be drawn nor refreshed. What I'd like to happen is to have the child widgets drawn over GL rendering, with transparent background.

    I've seen solutions using a QGraphicsView and QGraphicsScene, but they are applied programmaticaly, and I'd prefer everything to be managed through the designer.

    Is there any way to get the QGLWidget children drawn over the OpenGL scene with transparent background ?

    Thanks in advance for your help.

  • Hi,
    Did u resolve this problem?

  • Hello Floof,

    one solution is to use the mechanics of QGraphicsScene/View to embed widgets in a scene :

    Here, you have an example of doing OpenGL in the drawBackground of the Scene.

    Another way is to overpaint with a QPainter over your OpenGL scene :

    I think embedding directly over QWidget in a QGLWidget is problematic.



Log in to reply