Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem in making QWidget background transparent by setting WA_ContentsPropagated attribute.
Forum Updated to NodeBB v4.3 + New Features

Problem in making QWidget background transparent by setting WA_ContentsPropagated attribute.

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 8.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    Hi,

    I am loading a URL using QWebView(inherits QWidget), I would like to make the background of this widget transparent. As per the documentation at http://doc.qt.nokia.com/qq/qq16-background.html, I tried to set the attribute WA_ContentsPropagated for this widget but it is not working.

    Sample code :-

    @
    QWebView* webView = new QWebView();
    webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    webView->load(QUrl("http://s0.2mdn.net/2281014/PID_1862071_YvaExpandableMaster.swf"));
    webView->setAttribute(Qt::WidgetAttribute::WA_ContentsPropagated);

    webView->setGeometry(100,100,1000, 500);
    

    webView->show();
    @

    Please advice where I am going wrong.

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aashish.lg
      wrote on last edited by
      #2

      I am amazed to see that in this world of qt developers does nodody know the answer for this.....
      or atleast is it possible to give particular color and all that colored background will become transparent.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        You did wait about a day - patience is a virtue!

        We have holiday time in many parts of the world, so people are not in front of their workstations and answer developer's questions but sit together with their families.

        Additionally, whining at your fellow developers is not very likely to make them eager to help you.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aashish.lg
          wrote on last edited by
          #4

          Hi,

          I have given a try by setting QPalette for this widget. Since as per Qt doc this is the basic interface for any bg, foregrond color related change.
          while creating the Palette I have specifed brush as no brush and color as QColor which has alpha value as 0. Neverthless my widget is not becoming transparent but it is getting totally black.

          Below mention is the code.
          @
          QPalette pal;
          QBrush brush(Qt::NoBrush);
          QColor color(Qt::transparent);
          pal.setBrush(QPalette::Window,brush);
          pallete.setColor(QPalette::Window,color);
          QWidget window;
          window.setPalette(pal);
          window.setGeometry(10,10,250,250);
          window.show();
          @

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KA51O
            wrote on last edited by
            #5

            Maybe this "link":http://doc.qt.nokia.com/qq/qq16-background.html is helpful.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aashish.lg
              wrote on last edited by
              #6

              Thanks for suggestion. I have gone through this link multiple times , and got an idea that in Qt we can control color behaviour using QPalette, but not helping me . :(

              1 Reply Last reply
              0
              • K Offline
                K Offline
                KA51O
                wrote on last edited by
                #7

                Maybe "this":http://developer.qt.nokia.com/forums/viewthread/1107 one ? Just search this site for "transparent background". There are plenty threads about this.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aashish.lg
                  wrote on last edited by
                  #8

                  Hi Hobby,

                  Hats off to you man , I am able to achieve bg transparency by just three lines of code , mentioned in the link suggetsed by you.

                  Thank you very much for your timely help.
                  Regards
                  Ashish

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KA51O
                    wrote on last edited by
                    #9

                    Glad I could help. The credit should go to the guy who actually provided the solution, I just remembered reading something about this a while ago.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      aashish.lg
                      wrote on last edited by
                      #10

                      HI ,

                      I have just tested my transparency code in Suse Linux, which is having
                      Qt 4.6.3 run time libraries.
                      I am getting totally black window instead of transparent window and on commnad prompt

                      I am getting message as "QGtkStyle was unable to detect the current GTK+ theme."

                      Please help what is going wrong on Linux.
                      Am I missing some X11 related display driver on Linux machine

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved