Transparent QWidget over a QGLWidget
-
wrote on 13 Mar 2018, 08:31 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....
-
wrote on 14 Mar 2018, 15:21 last edited by Alain38 0
Hi,
Combine the setAttribute(Qt::WA_TranslucentBackground) with setWindowOpacity -
Also, if you are on Qt 5.4 or newer, I suggest replacing
QGLWidget
withQOpenGLWidget
.QOpenGLWidget
resolves numerous issues withQGLWidget
: https://blog.qt.io/blog/2014/09/10/qt-weekly-19-qopenglwidget/
1/3