Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Transparent QWidget over a QGLWidget

    General and Desktop
    qwidget qglwidget transparent
    3
    3
    1252
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NIXIN
      NIXIN last edited by

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

      QWidget *transparentWidget = new QWidget;
      transparentWidget->setFixedSize(1440, 720);
      transparentWidget->setAttribute(Qt::WA_TranslucentBackground);
      
      QGLWidget *glWidget  = new QGLWidget;
      transparentWidget->setParent(glWidget);
      transparentWidget->setGeometry(10, 50, 500, 500);
      
      transparentWidget->show();
      glWidget->show();
      

      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....

      1 Reply Last reply Reply Quote 0
      • A
        Alain38 0 last edited by Alain38 0

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

        1 Reply Last reply Reply Quote 0
        • JKSH
          JKSH Moderators last edited by

          Also, if you are on Qt 5.4 or newer, I suggest replacing QGLWidget with QOpenGLWidget. QOpenGLWidget resolves numerous issues with QGLWidget: https://blog.qt.io/blog/2014/09/10/qt-weekly-19-qopenglwidget/

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply Reply Quote 2
          • First post
            Last post