Important: Please read the Qt Code of Conduct -

Transparent QWidget over a QGLWidget

  • I am trying to have a transparent QWidget over a QGLWidget something like below:

    QWidget *transparentWidget = new QWidget;
    transparentWidget->setFixedSize(1440, 720);
    QGLWidget *glWidget  = new QGLWidget;
    transparentWidget->setGeometry(10, 50, 500, 500);

    But I am not getting the desired result. transparentWidget is being added at the specified geometry, however it is not transparent.

    How can I fix this??

    Any leads would be appreciated....

  • Hi,
    Combine the setAttribute(Qt::WA_TranslucentBackground) with setWindowOpacity

  • Moderators

    Also, if you are on Qt 5.4 or newer, I suggest replacing QGLWidget with QOpenGLWidget. QOpenGLWidget resolves numerous issues with QGLWidget: