QFrame: official shape/shadow to not fill background ?
-
Hi all,
I'm the author of QSvgStyle, and I would like to know if QFrame is just about drawing a frame without background ?
Currently I'm using the color of the frame's backgroundRole() to fill it with color. But I see other style engines like fusion do not fill it.
Is there a way to tell through shape/shadow whether we want the frame to be filled ?
I know about autoFillBackground() but this is managed by qt itself by filling the background with Window palette, regardless of the backgroundRole set to the frame.Thanks
-
Thanks. Do you know how the officiel Qt Fusion style handles frame fills ? Maybe I should follow it since it's made by Qt itself.
-
Hi,
To the best of my knowledge, I would say no. QFrame is a base widget for anything that requires a frame but it does not mean it needs to be transparent.
-
You could use
QMetaObject
to figure out whether a frame is a plainQFrame
(in which case you could fill it) or inherits from it (in which case you might rather leave it untouched). -
So in which case of shape/shadow should I fill the frame with its background color ?
-
I am not maintaining
QSvgStyle
.
Without knowing it's principles: I'd probably add a flag to the style itself, to toggle whether frame background will be applied only toQFrame
or to everything that inherits from it. Then I'd evaluateQt::WA_NoSystemBackground
and paint the background if the widget attribute is unset. -
Thanks. Do you know how the officiel Qt Fusion style handles frame fills ? Maybe I should follow it since it's made by Qt itself.
-
QFusionStyle::drawPrimitive()
doesn't explicitly draw a background forPE_Frame
. It draws backgrounds only for classes inheriting from it to the extent needed. Drawing that frame without explicit background, however, draws it on the default window background. If you have a frame as a top level widget, it looks as if its background had been explicitly drawn. -
Thank you, I'll have a look at its code to mimic its behavior.
-