Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QWidget transparent background (but not the children)

I have a QWidget that contains a QPixmap and a QComboxBox in its Layout. I would like to set the background of the widget transparent (but I want to show the QPixmap and the QComboBox normally). How do I do that?

like image 240
Vincent Avatar asked Nov 28 '25 04:11

Vincent


1 Answers

You can use the attribute

widget->setAttribute(Qt::WA_NoSystemBackground);

Qt documentation :

Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted. Note: Unlike WA_OpaquePaintEvent, newly exposed areas are never filled with the background (e.g., after showing a window for the first time the user can see "through" it until the application processes the paint events). This flag is set or cleared by the widget's author.

like image 134
MSA Avatar answered Nov 30 '25 17:11

MSA