1 Attachment(s)
Background image on a combined widget list
Hi, i'm trying to set a background image on a combined QWidget using stylesheets.
For combined QWidget i mean a qwidget A in which there is a layout containing some widgets, for example:
I have the class A that extends QWidget, in te constructor i have the following code to create a combined widget:
Code:
labelGroup->adjustSize();
labelIco->adjustSize();
labelIcoReceived->adjustSize();
labelTxt->adjustSize();
labelTime->adjustSize();
hLayout->addWidget(labelIcoReceived);
hLayout->addWidget(labelGroup);
hLayout->addWidget(labelIco);
hLayout->addWidget(labelService);
hLayout->addWidget(labelTime);
vLayout->addLayout(hLayout);
vLayout->addWidget(labelTxt);
setLayout(vLayout);
adjustSize();
If i try to append
Quote:
setStyleSheet("background-color: yellow");
The result is the following:
Attachment 5477
And obviously i don't want this, i wan't to spread the color all over the widget.
I would like to use stylesheets because i wan't to add a scalable border image to the background like the one explained here and showed here:
http://doc.trolltech.com/qq/qq20-borderimage.png
How can i do this?
Thanks!
Re: Background image on a combined widget list
It is most likely you have to set setAutoFillBackground to true. Then it should work. Also you might want to set the style sheet only for the widget, not for all children also.
Re: Background image on a combined widget list
Solved!
I have modified my qwidget A declaration, making it extends QFrame instead of QWidget and then using:
Code:
setStyleSheet("A{ background-color: yellow }");
in order not to propagate the style to children.
Thanks
P.S. This site helps to overcome these kind of problems. It explains how to set backgrounds on widgets of frames.