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. Prevent WA_TranslucentBackground Inheritance
QtWS25 Last Chance

Prevent WA_TranslucentBackground Inheritance

Scheduled Pinned Locked Moved Solved General and Desktop
watranslucentb
5 Posts 2 Posters 2.0k Views
  • 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.
  • brixelB Offline
    brixelB Offline
    brixel
    wrote on last edited by brixel
    #1

    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.

    kshegunovK 1 Reply Last reply
    0
    • brixelB 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.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @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

      brixelB 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @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.

        brixelB Offline
        brixelB Offline
        brixel
        wrote on last edited by
        #3

        @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.

        kshegunovK 1 Reply Last reply
        0
        • brixelB brixel

          @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.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          @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
          1
          • brixelB Offline
            brixelB Offline
            brixel
            wrote on last edited by brixel
            #5

            Thanks, will keep that in mind.

            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