Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebEngineView with transparent bg always on top



  • What I expect:

    • QWebEngineView with a translucent background

    • QWidget overlay on QWebEngineView

    Codes are:

    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QMainWindow mainWindow;
    
        QWebEngineView view(&mainWindow);
        view.setUrl(QUrl("https://www.qt.io"));
        view.setGeometry(50, 50, 300, 300);
    
        view.page()->setBackgroundColor(Qt::transparent); /// <- #1 make web engine view bg transparent
    
        QWidget overlay(&mainWindow);
        overlay.setGeometry(0, 0, 100, 100);
        overlay.raise(); /// <- #2 make overlay widget on top
        overlay.setStyleSheet("background:red");
    
        mainWindow.resize(400, 400);
        mainWindow.show();
        return app.exec();
    }
    

    Result is:
    d30daae1-1769-43e1-85de-e87aa9556d45-image.png

    Problem is:
    QWebEngineView overlayed on QWidget.
    QWidget cannot overlay on QWebEngineView when QWebEngineView has transparent bg.

    How to solve it?

    ps: problem appears on Windows 10, Qt 5.15.0 with msvc2019



  • This post is deleted!

Log in to reply