Transparent Background in QWebEnginePage

大城市里の小女人 提交于 2019-12-04 05:59:49

As mentioned in https://bugreports.qt.io/browse/QTBUG-41960, this is now working by simply using this line:

webEngineView->page()->setBackgroundColor(Qt::transparent);

I've tried it in Qt 5.6 and it works well.

Update: In order to make this answer more helpful, let me show all relevant code.

In MainWindow, I have set this:

setAttribute(Qt::WA_TranslucentBackground);
setAutoFillBackground(true);
setWindowFlags(Qt::FramelessWindowHint);

For the webEngineView object, I have set these attributes:

webEngineView->setAttribute(Qt::WA_TranslucentBackground);
webEngineView->setStyleSheet("background:transparent");
webEnginePage = webEngineView->page();
// https://bugreports.qt.io/browse/QTBUG-41960
webEnginePage->setBackgroundColor(Qt::transparent);

I hope it helps.

No. A partial solution has been committed to upstream, but it covers only QtQuick and you can't have any elements on top:

https://bugreports.qt.io/browse/QTBUG-41960

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!