Bug 29414
Summary: | [Qt] [Regression] Transparent QWebView | ||
---|---|---|---|
Product: | WebKit | Reporter: | Tor Arne Vestbø <vestbo> |
Component: | Layout and Rendering | Assignee: | QtWebKit Unassigned <webkit-qt-unassigned> |
Status: | RESOLVED WONTFIX | ||
Severity: | Normal | CC: | hausmann, jesus, kenneth, kent.hansen, tonikitoo |
Priority: | P2 | Keywords: | Qt, QtTriaged |
Version: | 528+ (Nightly build) | ||
Hardware: | Other | ||
OS: | OS X 10.5 | ||
Bug Depends on: | |||
Bug Blocks: | 35784 |
Tor Arne Vestbø
This bug report originated from issue QTBUG-3706
<http://bugreports.qt.nokia.com/browse/QTBUG-3706>
--- Description ---
The result of the code below is a fully-transparent background in the HTML page, so that one can overlay it over an existing widget background. This worked in Qt 4.4.3, but not anymore in 4.5.0. The page renders with a solid white background instead.
Test case (needs an image):
//----------------------------------------------------
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *widget = new QWidget;
widget->setStyleSheet("QWidget {background: url(background.png)}");
QVBoxLayout *vbox = new QVBoxLayout(widget);
QWebView *webView = new QWebView;
vbox->addWidget(webView);
QPalette p = webView->palette();
p.setColor( QPalette::Dark, Qt::transparent );
webView->setPalette(p);
p = webView->page()->palette();
p.setColor( QPalette::Window, Qt::transparent );
webView->page()->setPalette(p);
webView->setHtml("<body style='background: rgba(0,0,0,0)'>"
"<h1 style='color:white'>Test</h1></body>");
widget->show();
return a.exec();
}
//----------------------------------------------------
--- Comments ---
Note: qtuser: 03/09/09 03:32:05 PM:
Here's a fix/workaround for this issue:
The difference between Qt 4.4 and 4.5 is that in Qt 4.4, the background is first filled with QPalette::Dark by the QWebView followed by QPalette::Window by the QWebPage. In Qt 4.5, the page background is only filled with the QPalette::Base color. Making that color transparent in the palette of the QWebView allows the page to be transparent again. However, a small change to the Qt source is also necessary in order for painting to work properly:
In the file src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp, in QWebView::setPage(), remove the following line:
setAttribute(Qt::WA_OpaquePaintEvent, d->page);
I would say the 4.5 behavior is better. It's just different from 4.4 -- but maybe nobody else was doing transparent QWebViews, so I'd rather stick with the 4.5 behavior (with the above fix).
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Jesus Sanchez-Palencia
Blocking 2.0 just until we confirm if this is a regression or not.
Simon Hausmann
This is indeed intentional. The opaque paint event flag by default allows for optimizations in Qt. It's easy to disable it from the application side in the rare case the webview is meant to be transparent:
http://labs.trolltech.com/blogs/2009/06/30/transparent-qwebview-or-qwebpage/