[Qt-interest] QPushButton icon size

Arnold Krille arnold at arnoldarts.de
Wed Apr 15 17:40:04 CEST 2009


Hi,

On Wednesday 15 April 2009 15:51:09 Riccardo Roasio wrote:
> i'm trying to set an icon for a button but i'm not able to set its
> dimension properly...
>  QIcon *calculatorIcon=new QIcon();
> calculatorIcon->addFile("/home/citec/development/Qt/Test/icons/calculator.p
>ng");
>  calculatorButton= new QPushButton(*calculatorIcon,"",this);
> calculatorButton->setFixedSize(64,64);

Apart from the fact that you can't expect a 64x64 icon to display properly on 
a 64x64 button when the style is taken into account...

> What's wrong with this piece of code?
> I'm expecting the icon to become 64x64 pixel... (the original icon is 64x64
> png image)

...te fun thing about QIcon is that it ships the icons in the size and state 
the receiver wants it.
You want to look at 
http://doc.trolltech.com/4.5/qabstractbutton.html#iconSize-prop and then set 
the icon-size property on your pushbutton. This should a) make the icon in the 
size you want and b) adopt the size of the pushbutton to have the full icon, 
(optionally) the text and the full border and decoration from the style...

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090415/00bcd3ef/attachment.bin 


More information about the Qt-interest-old mailing list