Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Prevent WA_TranslucentBackground Inheritance

    General and Desktop
    watranslucentb
    2
    5
    1464
    Loading More Posts
    • 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.
    • brixel
      brixel last edited by brixel

      Hello,

      I have a desktop application that uses FramelessWindowHint and WA_TranslucentBackground. There is an area at the top that the transparency is allowed to show through and in that area I have a widget that fills the space with color and opacity set so there is color, but you can still see the desktop below.

      Everything seems to inherit the translucent background property of the main window and becomes invisible. The solution for this particular case was to use a solid color image as the background for the widget and set the opacity of the widget, however this is only working in Windows and not on OSX. Not really sure why it's working in Windows, because when I set the background color it didn't, only works when I use an image.

      I've tried a few approaches such as drawing the shape in the space, using an image in a graphics view, etc., but they all vanish with we enable WA_TranslucentBackground.

      Is there a way to prevent this inheritance so children objects can have independent values? If not, is there a different approach I can take to make this work across Windows and OSX? Thanks for any help.

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @brixel last edited by

        @brixel
        Hello,

        I have a desktop application that uses FramelessWindowHint and WA_TranslucentBackground. There is an area at the top that the transparency is allowed to show through and in that area I have a widget that fills the space with color and opacity set so there is color, but you can still see the desktop below.
        Everything seems to inherit the translucent background property of the main window and becomes invisible.

        I'd lie if I say I'm not guessing here, but I believe that's because by default child widgets are alien (what a word for non-native). You could try making them all native, however that might make your application crawl.

        Kind regards.

        Read and abide by the Qt Code of Conduct

        brixel 1 Reply Last reply Reply Quote 0
        • brixel
          brixel @kshegunov last edited by

          @kshegunov said:

          all native

          Your suggestion does work. I only made the one widget in question native. I'll keep an eye on the performance concern.

          Thank you for the assistance.

          kshegunov 1 Reply Last reply Reply Quote 0
          • kshegunov
            kshegunov Moderators @brixel last edited by kshegunov

            @brixel said:

            Your suggestion does work. I only made the one widget in question native. I'll keep an eye on the performance concern.

            Passing the Qt::WA_NativeWindow flag will cause all ancestors to become native too. If you don't want that, you have to add the Qt::WA_DontCreateNativeAncestors flag as well, as duly noted in the documentation.

            Kind regards.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply Reply Quote 1
            • brixel
              brixel last edited by brixel

              Thanks, will keep that in mind.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post