PDA

View Full Version : Resize image to fill a QPushButton ?



hungpham90
15th October 2011, 03:18
Hi! I'm newbie in Qt mobile! I have a problem when i load an image into a QPushButton. I loaded it! But the size of image is larger than the size of button! I want to reduce the size of image to fill the button! This is my code :

// Set image for button
QPixmap *image= new QPixmap("C:\\Symbian\\Project\\Images\\mypic.png");
QIcon icon(*image);
QSize iconSize(image->width(), image->height());
ui->button->setIcon(icon);
ui->button->setIconSize(iconSize);
Help me ! Thanks a lot!

Lykurg
15th October 2011, 11:33
Use QPushButton::setIcon and QPushButton::setIconSize directly without anything else. Qt will scale the image for you!
ui->button->setIcon(QIcon("C:\\Symbian\\Project\\Images\\mypic.png"));
ui->button->setIconSize(QSize(22,22));

hungpham90
17th October 2011, 16:58
Thanks a lot! By the way, I want to create a dialog with some buttons and vertical layout and i used QScrollarea ! I drag and drop it in my dialog! Why didn't the scrollarea run ? I'm programming it for Nokia E71. (i'm not good at English! Sorry :D)

Esther
21st March 2013, 10:00
is anyone taking this mobile image resize program (http://www.rasteredge.com/how-to/csharp-imaging/resize-image/)?and can anyone suggest me some better image rotate and resize software that i can download and install on my mobile? thx.

peterlee
1st November 2013, 02:21
Are you looking for the image resizing program (http://www.yiigo.com/guides/csharp/how-to-resize-image.shtml)? Have you found your way out? I am testing with the related Imaging SDKs (http://www.yiigo.com/guides/csharp/) these days. I want to find some manual tools which can be customized by users according to their own favors. Do you have any good suggestion? Thanks in advance.



Best regards,
Arron

silliboy
26th November 2013, 04:39
It's a great pleasure to visit your website and to enjoy your excellent work. You have fime ideas. Really looking forward to read more.