Setting transparent background for QWebView

I am trying to set a transparent background to an element QWebView.

+---------------------------+
| x | Window title          | <<< Hidden borders and title bar
+---------------------------+     view->setWindowFlags(Qt::FramelessWindowHint);
|                           |
|     ******************    |   
|    ********************<--|------- This is the HTML side (a rectangle with
|     ******************    |        rounded corners)
|                         <-|-- with transparent background that must
+---------------------------+   remain transparent for the desktop window

I was looking for how to set a transparent background for webview, and found this code in all places:

QPalette pal = view->palette();
pal.setBrush(QPalette::Base, Qt::transparent);
view->page()->setPalette(pal);
view->setAttribute(Qt::WA_OpaquePaintEvent, false);

The above code is not working properly. This is what my window looks like:

So the problem is that the gray part MUST be transparent. How can i solve this?

I use the following code to decode a window.

view->setWindowFlags(Qt::FramelessWindowHint);
+4
source share
1 answer

This works for me:

view->setStyleSheet("background:transparent");
view->setAttribute(Qt::WA_TranslucentBackground);
+5
source

All Articles