Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QT widgets and transparency
shwong2002 last edited by
I have two custom QT widgets (basically opengl QT widgets) inside a QMainWindow.
I want the QMainWindow to be transparent, but I still want what is rendered in the Opengl widgets to be opaque.
I cannot seem to do this. When I set the main window as transparent, the widgets become transparent too even if I modify the attributes, background roll, and AutobackgroundFill of the widget. In this case, I basically have everything transparent -- here is my code, which is in the constructor of the QMainWindow. Any ideas of what is wrong? Thanks!
//try to make the window transparent
setAttribute(Qt::WA_TranslucentBackground); //this line makes everything dissapear!!!
Jeroentjehome last edited by
Hi, The stylesheet/code you posted is almost unreadable. Please place it within Code block. The stylesheet is a very powerfull option for widgets. I also encountered a similar problem. The stylesheet of the parent will also be the stylesheet for the widgets. When you want a stylesheet only active for a single type of widget you could try the following:
This will set the border image only for the QMainWindow and if your child widgets will not be (or inherit) a QMainWindow there stylesheets will be left unchanged.
Hope this helps, but to help you even better, place the code in a code block please.