Prevent WA_TranslucentBackground Inheritance
-
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.
-
@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.
-
@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 theQt::WA_DontCreateNativeAncestors
flag as well, as duly noted in the documentation.Kind regards.