3

I'm developing Qt5 webview based application and I need to make a specific color inside webview be transparent or have an alpha channel. For example, web page, loaded into webview, may have fullscreen div with a background color (black in most cases, but may be another color). I need to make this color (with webview itself) be semi-transparent. All others elements on the application form should be visible through this webview.

VaMpir
  • 61
  • 2
  • 6

1 Answers1

1

I think I understand your question, you want to let the WebView with the semi-opaque background (or something).

You can try to remove the background of webview, use this (source: https://gist.github.com/anonymous/103126 ):

QPalette palette = ui->webView->palette(); //Get webView palette
palette.setBrush(QPalette::Base, Qt::transparent);
ui->webView->page()->setPalette(palette); //Set transparent palette
ui->webView->setAttribute(Qt::WA_OpaquePaintEvent, false);//Remove opaque

In your css file (into html), use this:

<html>
<head>
body {
   background-color: rgba(255, 0, 0, 0.2);//Edit "0.2" to obtain the opacity needed.
}
</head>
<body>
Something...
</body>
</html>
Protomen
  • 9,471
  • 9
  • 57
  • 124