Results 1 to 5 of 5

Thread: QWebView transparent problem

  1. #1
    Join Date
    Jan 2009
    Posts
    1
    Platforms
    Windows

    Default QWebView transparent problem

    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.

    Qt Code:
    1. class WebView : public QWebView
    2. {
    3.  
    4. public:
    5. WebView()
    6. {
    7. pixmap = new QPixmap(size());
    8. }
    9. ~WebView()
    10. {
    11. delete pixmap;
    12. }
    13. protected:
    14. void resizeEvent(QResizeEvent* event)
    15. {
    16. QWebView::resizeEvent(event);
    17. pixmap->fill(Qt::transparent);
    18. QPainter::setRedirected(this, pixmap);
    19. QPaintEvent pe(rect());
    20. paintEvent(&pe);
    21. QPainter::restoreRedirected(this);
    22. setMask(pixmap->mask());//
    23.  
    24. }
    25. private:
    26. QPixmap* pixmap;
    27. };
    28. int main(int argc, char* argv[])
    29. {
    30. QApplication a(argc, argv);
    31. WebView* webView = new WebView();
    32. QPalette palette = webView->palette();
    33. webView->load(QUrl("http://www.google.com/"));
    34.  
    35. webView->show();
    36. return a.exec();
    37. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 14th January 2009 at 22:41. Reason: changed [quote] to [code] tags

  2. #2

    Default Re: QWebView transparent problem

    I've tried to set palette of webview, but the background turns out to be full transparent (nothing on the screen, totally transparent...), what's the problem, anybody help?

    Qt Code:
    1. WebView() {
    2. QPalette pal = palette();
    3. pal.setBrush(QPalette::Window, Qt::transparent);
    4. setPalette(pal);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by naruto_9w; 15th January 2009 at 14:02.

  3. #3

    Default Re: QWebView transparent problem

    Anybody help? Thanks!

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView transparent problem

    Dont do anything,,, just use QWidget::setWindowOpacityIt will set the transparency for the whole widget.

  5. #5

    Default Re: QWebView transparent problem

    Quote Originally Posted by aamer4yu View Post
    Dont do anything,,, just use QWidget::setWindowOpacityIt will set the transparency for the whole widget.
    Thanks for your answer first!

    The method you mentioned do be able to solve the transparency problem of a *whole* widget, nevertheless, our purpose is to leave the background transparent, while make the contents (for example, a button, an input, etc) opaque, somehow like the effect of Yahoo! desktop widget.

    So any suggestion for these? Thanks!

Similar Threads

  1. Problem With QWebView
    By ivi2501 in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2009, 20:37
  2. Transparent QScrollbar groove in QWebView
    By Jonas in forum Qt Programming
    Replies: 0
    Last Post: 20th October 2008, 09:55
  3. Problem in QWebView
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2008, 20:27
  4. QWebView problem with pdf
    By oscar in forum Qt Programming
    Replies: 5
    Last Post: 23rd August 2008, 16:37
  5. QWebView unknown problem
    By morfei in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 01:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.