Results 1 to 6 of 6

Thread: Resize image to fill a QPushButton ?

  1. #1
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Resize image to fill a QPushButton ?

    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 :
    Qt Code:
    1. // Set image for button
    2. QPixmap *image= new QPixmap("C:\\Symbian\\Project\\Images\\mypic.png");
    3. QIcon icon(*image);
    4. QSize iconSize(image->width(), image->height());
    5. ui->button->setIcon(icon);
    6. ui->button->setIconSize(iconSize);
    To copy to clipboard, switch view to plain text mode 
    Help me ! Thanks a lot!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Resize image to fill a QPushButton ?

    Use QPushButton::setIcon and QPushButton::setIconSize directly without anything else. Qt will scale the image for you!
    Qt Code:
    1. ui->button->setIcon(QIcon("C:\\Symbian\\Project\\Images\\mypic.png"));
    2. ui->button->setIconSize(QSize(22,22));
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Lykurg for this useful post:

    hungpham90 (17th October 2011)

  4. #3
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Resize image to fill a QPushButton ?

    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 )

  5. #4
    Join Date
    Mar 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Android

    Default Re: Resize image to fill a QPushButton ?

    is anyone taking this mobile image resize program?and can anyone suggest me some better image rotate and resize software that i can download and install on my mobile? thx.

  6. #5

    Default Re: Resize image to fill a QPushButton ?

    Are you looking for the image resizing program? Have you found your way out? I am testing with the related Imaging SDKs 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

  7. #6
    Join Date
    Nov 2013
    Posts
    2
    Qt products
    Qt/Embedded
    Platforms
    Maemo/MeeGo

    Default Re: Resize image to fill a QPushButton ?

    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.

Similar Threads

  1. Qt Designer QPushButton resize dimensions
    By qtnewbi3 in forum Qt Tools
    Replies: 0
    Last Post: 13th July 2011, 18:10
  2. QPushButton resize event
    By gcubar in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2011, 14:04
  3. Resize Image
    By kamlesh.sangani in forum General Programming
    Replies: 5
    Last Post: 15th January 2011, 12:51
  4. How to resize the QIcon inside QPushButton dynamically?
    By gboelter in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2010, 13:34
  5. QStackedWidget fill Postscript image And scroll problem
    By patrik08 in forum Qt Programming
    Replies: 11
    Last Post: 22nd April 2007, 10:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.