PDA

View Full Version : How to fill label backgroud with picture?--- finished



kenchan
14th December 2012, 06:15
Hi All,

eg.
i have a picture which size is 100*100 , and the label size is 200*200, i want to the picture fill the label , whent the label's size change, the background can be changed also and fitted the label.(eg. when the label's size is 500*500, the picture's size must change to 500*500 so than fit the label)

i use the below code ,but cann't not realize.

label->setStyleSheet("QLabel{background-image:url(:/images/labelbackground_click.png)}");

or

backgroudPalette.setBrush(label->backgroundRole(), QBrush(QPixmap(":/images/bg.png")));
label->setPalette(backgroudPalette);
label->setAutoFillBackground(true);



Please give me any advice.

thanks and best regards.

ken

wysota
14th December 2012, 09:55
Why not simply use QLabel::setPixmap() and set scaled contents to true?