Hi all,
I want to have a transparent QWebView. Now, I can make a transprent window by this thread.
As I know, QWebView is a child of QWidget. But when I use webView->load(QUrl("http://www.google.com/"));, the window of QWebView is not transparent. Can I make the QWebView appear as text on the desktop? Anyone who can help me.
here is my code.
class WebView : public QWebView
{
public:
WebView()
{
}
~WebView()
{
delete pixmap;
}
protected:
{
QWebView::resizeEvent(event);
pixmap->fill(Qt::transparent);
paintEvent(&pe);
setMask(pixmap->mask());//
}
private:
};
int main(int argc, char* argv[])
{
WebView* webView = new WebView();
webView
->load
(QUrl("http://www.google.com/"));
webView->show();
return a.exec();
}
class WebView : public QWebView
{
public:
WebView()
{
pixmap = new QPixmap(size());
}
~WebView()
{
delete pixmap;
}
protected:
void resizeEvent(QResizeEvent* event)
{
QWebView::resizeEvent(event);
pixmap->fill(Qt::transparent);
QPainter::setRedirected(this, pixmap);
QPaintEvent pe(rect());
paintEvent(&pe);
QPainter::restoreRedirected(this);
setMask(pixmap->mask());//
}
private:
QPixmap* pixmap;
};
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
WebView* webView = new WebView();
QPalette palette = webView->palette();
webView->load(QUrl("http://www.google.com/"));
webView->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks