Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.15.2
Description
QWebEngineView with transparent bg always on top
//Test Code 1 int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow mainWindow; QWebEngineView view(&mainWindow); view.setUrl(QUrl("https://www.baidu.com")); view.setGeometry(50, 50, 300, 300); view.page()->setBackgroundColor(Qt::transparent); QWidget overlay(&mainWindow); overlay.setGeometry(0, 0, 100, 100); overlay.raise(); overlay.setStyleSheet("background:red"); QPushButton button(&mainWindow); button.setGeometry(100, 0, 100, 100); button.setText("button"); mainWindow.resize(400, 400); mainWindow.show(); return app.exec(); }
//Test Code 2 int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow mainWindow; QWebEngineView *view = new QWebEngineView(&mainWindow); view->setGeometry(50, 50, 300, 300); view->setHtml("<html><head><style>" "h1 {background-color: #00ff00;}</style></head>" "<body><h1>This is heading 1</h1></body></html>", QUrl("http://localhost")); view->page()->setBackgroundColor(Qt::transparent); QWidget overlay(&mainWindow); overlay.setGeometry(0, 0, 100, 100); overlay.raise(); overlay.setStyleSheet("background:red"); QPushButton button(&mainWindow); button.setGeometry(100, 0, 100, 100); button.setText("button"); mainWindow.resize(400, 400); mainWindow.show(); QObject::connect(&button, &QPushButton::clicked, [ = ]() { static bool transparent = false; view->page()->setBackgroundColor(transparent ? Qt::transparent : Qt::white); transparent = !transparent; }); return app.exec(); }
If I set "view.page()->setBackgroundColor(Qt::transparent);", the overlapping area of QWidget and QPushButton to QWebEngineView cannot be displayed.
If I don't set "view.page()->setBackgroundColor(Qt::transparent);", I can display the overlapping area of QWidget and QPushButton to QWebEngineView.
Attachments
Issue Links
- is duplicated by
-
QTBUG-94166 QWebEngine with transparent properties, always on top. other QWidget and QPushButton cannot be rendered
- Closed