Congratulations to our 2022 Qt Champions!

Qt 5.0 transparent background QWebView above QWidget with video

  • Hello!

    I can not get a QWebView with a html code to be transparent when it is on top of a QWidget with a video running.

    Any tips to fix that? I found nothing on web and I read something about QGraphicsView but no success at all.

    int main(int argc, char *argv[]) {

    QApplication app(argc, argv);
    QWidget window;
    window.resize(500, 500);
    window.setStyleSheet("background-color: blue;");
    const char* file = "/home/vntsyne/Documents/avatar_60.mkv";
    QVlcPlayer player(&window);
    player.setGeometry(0, 0, 500,500);
    QWebView *view = new QWebView(&window);
    QPalette pal = view->palette();
    pal.setBrush(QPalette::Base, Qt::transparent);
    view->setAttribute(Qt::WA_OpaquePaintEvent, false);
    view->setHtml("<body >"
                  "<h1 >Test</h1>&lt;/body&gt;");
    view->setGeometry(200, 200, 100, 100);;
    return app.exec();

    "Screenshot from video:":

Log in to reply