embedyy
14th January 2009, 17:43
Hi all,
I want to have a transparent QWebView. Now, I can make a transprent window by this thread (http://www.qtcentre.org/forum/p-transparency-setmask-createheuristicmask-createmaskfromcolor-qpixmap-post28500/postcount4.html).
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()
{
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();
}
I want to have a transparent QWebView. Now, I can make a transprent window by this thread (http://www.qtcentre.org/forum/p-transparency-setmask-createheuristicmask-createmaskfromcolor-qpixmap-post28500/postcount4.html).
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()
{
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();
}