[Qt-interest] How can I change a button's background?

Alexandre Beraud aberaud at infflux.com
Fri Jun 19 12:13:11 CEST 2009


Hi again,

If you want to change the background when pressing the button, then you 
have to use the :pressed pseudo state. Take a look at:
http://doc.trolltech.com/4.4/stylesheet-examples.html#customizing-qpushbutton
If you can't see a different background *at all*, make sure the bk.png 
file is in the right directory, since you use "./bk.png". Maybe it can't 
find the picture at all.

Regards,

Alex


Kermit Mei a écrit :
> On Fri, 2009-06-19 at 11:53 +0200, Oliver Demetz wrote:
>   
>> Hi!
>> You are trying to reimplemtent a feature which is already available out 
>> of the box from the lib.
>> Have a look into StyleSheets, eg
>> button.setStyleSheet("background-image:url(./img.png);");
>> Regards,
>> Oliver
>>     
>
> I know styleSheet, but I also can Not see any different effect when I
> press. I use this sentence:
> rBtn.setStyleSheet("border-style:solid;background-image:url(./bk.png);");
>
> And another question: the background picture's size can't increase with
> the button itself.
>
> If there's many buttons, will it make my program run slowly? I need it
> run on ARM 9.
>
> Thanks for your help:)
>
> <snip>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com





More information about the Qt-interest-old mailing list