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.
  • B Offline
    B Offline
    brixel
    wrote on 17 Feb 2016, 16:43 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.

    K 1 Reply Last reply 17 Feb 2016, 16:54
    0
    • B brixel
      17 Feb 2016, 16:43

      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.

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 17 Feb 2016, 16:54 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

      B 1 Reply Last reply 17 Feb 2016, 17:08
      0
      • K kshegunov
        17 Feb 2016, 16:54

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

        B Offline
        B Offline
        brixel
        wrote on 17 Feb 2016, 17:08 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.

        K 1 Reply Last reply 17 Feb 2016, 17:16
        0
        • B brixel
          17 Feb 2016, 17:08

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

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 17 Feb 2016, 17:16 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
          • B Offline
            B Offline
            brixel
            wrote on 17 Feb 2016, 17:36 last edited by brixel
            #5

            Thanks, will keep that in mind.

            1 Reply Last reply
            0

            1/5

            17 Feb 2016, 16:43

            • Login

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