How to prevent child widgets from rendering outside the bounds of their parent widget?
-
Hi, I have a window with a windowless flag that I'm using as a splash screen.
I'm using a QFrame 'shadow_frame' for a shadow effect, and another QFrame that inherits from a QLabel to display gifs called 'main_frame'. They're both the same size.
If I set the 'main_frame' background to transparent, you can see the bounds of the shadow_frame
QFrame#shadow_frame{ background-color: red; border-radius: 30px; } QFrame#main_frame { background-color: transparent; }
If I set the background color of the 'main_frame' to a solid color, it goes outside the bounds of 'shadow_frame'
QFrame#shadow_frame{ background-color: red; border-radius: 30px; } QFrame#main_frame { background-color: green; }
-
Hi, I have a window with a windowless flag that I'm using as a splash screen.
I'm using a QFrame 'shadow_frame' for a shadow effect, and another QFrame that inherits from a QLabel to display gifs called 'main_frame'. They're both the same size.
If I set the 'main_frame' background to transparent, you can see the bounds of the shadow_frame
QFrame#shadow_frame{ background-color: red; border-radius: 30px; } QFrame#main_frame { background-color: transparent; }
If I set the background color of the 'main_frame' to a solid color, it goes outside the bounds of 'shadow_frame'
QFrame#shadow_frame{ background-color: red; border-radius: 30px; } QFrame#main_frame { background-color: green; }
@Mizmas said in How to prevent child widgets from rendering outside the bounds of their parent widget?:
They're both the same size
This is the problem, not that the child is rendering outside of the parent (it does not).
Make your main_frame smaller than its parent. -
@Mizmas said in How to prevent child widgets from rendering outside the bounds of their parent widget?:
They're both the same size
This is the problem, not that the child is rendering outside of the parent (it does not).
Make your main_frame smaller than its parent.@jsulm They're the both the same size because one frame is used for the shadow effect only, and the other for displaying a gif that has a textured background, which is also the same size as both frames, obviously you can just round the corners of the gif, but I'm looking for more straightforward solution.
In css there's a "overflow: hidden;
" property, but in QT it doesn't work. -
@jsulm They're the both the same size because one frame is used for the shadow effect only, and the other for displaying a gif that has a textured background, which is also the same size as both frames, obviously you can just round the corners of the gif, but I'm looking for more straightforward solution.
In css there's a "overflow: hidden;
" property, but in QT it doesn't work.