Z-order issue for transparent WebengineViews in Qt6
-
I know that WebEngineViews are using the Qt::WA_AlwaysStackOnTop attribute to properly put the views above everything else - if the background is set to Transparent color. In Qt5 I could show the views in intended z-order if I added them to the layout in the correct order.
In Qt6 this has changed. It seems that regardless of the order I add the views to the layout, the web page with transparent background (set in the page's css) will always be shown above the web page with an opaque background (set in the page's css).
How can I use the views in the z-order I want?
QWebEngineView *view = new QWebEngineView(parent); view->load(QUrl("http://qt-project.org/")); view->page()->setBackgroundColor(Qt::transparent); QWebEngineView *view2 = new QWebEngineView(parent); view2->load(QUrl("https://test.com/transparent_page.html")); view2->page()->setBackgroundColor(Qt::transparent); QStackedLayout* stackedLayout = new QStackedLayout(); stackedLayout->setStackingMode(QStackedLayout::StackAll); stackedLayout->addWidget(view2); stackedLayout->addWidget(view); setLayout(stackedLayout);
The above code will put the "view" (qt-project.org page) above "view2" (transparent web page) in Qt5, but in Qt6 "view2" will always be above "view" regardless in which order I add them to the layout.