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!!!
setStyleSheet(“background:transparent;”);
setWindowFlags(Qt::FramelessWindowHint);
ui.glWidgetChai->setAutoFillBackground(true);
ui.glWidgetChai->setAttribute(Qt::WA_OpaquePaintEvent);
ui.glWidgetChai->setBackgroundRole(QPalette::Button);
//ui.layoutTopView->addWidget(glWidgetChai2);
ui.glWidgetChai2->setAutoFillBackground(true);
ui.glWidgetChai2->setAttribute(Qt::WA_OpaquePaintEvent);
ui.glWidgetChai2->setBackgroundRole(QPalette::Button);
↧