Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Adding semi-transparent widgets on a custom QGLWidget
Keith A last edited by
I am looking for some insight from the community on dealing with custom QGLWidgets and semi transparent QWidget overlays. I have seen similar questions asked all around the web but I have not seen any solid responses. Below is a summary of the current situation I am experiencing.
What I have:
- A custom QGLWidget.
- Performance was the driving cause behind the use of the QGLWidget.
- Using Qt 4.6.3
- The QGLWidget renders using openGL commands within the paintEvent. This approach was derived from the Qt over-painting(bubbles) sample.
What I am trying to do:
- Overlay QWidget objects with semi-transparency on top of our custom QGLWidget.
What is the problem:
- The transparency is not working. More specifically, as the widget transparency increases the element look darker on the screen. When an object is completely transparent it appears black on the screen.
What I have tried to resolve the problem:
- Experimenting with different window flags and attribute flags on both the custom QGLWidget and on the overlay QWidgets.
- Tried using stylesheet manipulation on the QWidget overlay items.
- Tried using a QGraphicsView with my custom QGLWidget as the viewport. This issue causes a different problem. In this case I am not able to get the rendered components from the custom QGLWidget to appear on the screen.
Am I doing the right thing/What “should” I be doing?
- Should I use something other than QGLWidget?
- Are their solutions to this issue in more current releases of Qt (i.e. Qt 4.7)
- Should I move my rendering logic somewhere else
- I have researched some potential alternatives but I am looking for some insight here before I march down any particular path.
- Semi transparent dialog windows do appear correctly on top of the custom QGLWidget but they flicker whenever the custom QGLWidget has to redraw.
With all this in mind here are the actual questions:
- Is it possible to have semi transparent QWidgets on top of a QGLWidget in Qt 4.6?
- If it is possible, is this approach feasible?
- If it is not possible, is there any other way to overlay QWidgets with objects that render using openGL?
jbarron last edited by
Perhaps the following Qt Quarterly article will help:
lcampagn last edited by
I am having exactly the same problem. To restate: a partially transparent QWidget renders incorrectly when over a QGLWidget.
For me, embedding the transparent widget inside the QGLWidget is not possible, since the widget is confined to the boundaries of the entire window, not just the QGLWidget.
Does anyone have a solution?
Anyone know if this is definitely not possible?