Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User prajna123's Avatar
    Join Date
    Jan 2008
    Posts
    48
    Dear All,
    I am trying to display the images on the buttons.
    I am able to display it.........But what I want is irrespective of the size(That is,less or of greater size than button parameters.)of the image, picture should fit exactly into the button size.

    Images gets displayed upon buttons if greater or less than the button size but it won't get fit into the button parameters.
    I have set the icon size to the button size using mainImage->setIconSize(QSize(100,160)); API.

    But its not taking any effect.....
    Need help on this.....

    Below is the code I am using..
    mainImage = new QPushButton(this);
    mainImage->move(25,210);
    mainImage->setIconSize(QSize(100,160));
    mainImage->setGeometry(70,10,100,160);
    mainImage->setFocusPolicy(Qt::TabFocus);
    mainImage->show();

    QString Imagename(*it5);
    NextImagepath = "c:\\Data\\Images\\Pictures\\"+Imagename;
    QPixmap imagedisplay(NextImagepath);
    QIcon icon(imagedisplay);
    mainImage->setIcon(icon);


    I am using .jpg image of size 41KB.

    Note:
    I am using Qt-S60 temple release.

    Thanks,
    Prajna

  2. #2
    Nokia Developer Champion james1980's Avatar
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    916
    Hi prajna123,

    What pixel size image you are using for the displaying on the button?

    You can try resizeing your pixmap.
    Use the code
    Code:
    imagedisplay.scaledToHeight(88);
    imagedisplay.scaledToWidth(88);
    Hope this will helps you.

    Regards
    Jajal Mehul

  3. #3
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Also check if QPixmap::scaled() will help.

  4. #4
    Registered User prajna123's Avatar
    Join Date
    Jan 2008
    Posts
    48
    I am using image of pixel size 270 * 216
    May be we have to maintain the aspect ratio


    Tried using
    imagedisplay.scaledToHeight(88);
    imagedisplay.scaledToWidth(88); but it is not taking any effect

    Need help on this

  5. #5
    Nokia Developer Champion james1980's Avatar
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    916
    Quote Originally Posted by prajna123 View Post
    I am using image of pixel size 270 * 216
    May be we have to maintain the aspect ratio


    Tried using
    imagedisplay.scaledToHeight(88);
    imagedisplay.scaledToWidth(88); but it is not taking any effect

    Need help on this
    Hi,
    Your image size is changed or remain as it is?
    Jajal Mehul

  6. #6
    Nokia Developer Champion james1980's Avatar
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    916
    Hi,
    One more thing, its not necessary to maintain the aspect ratio also. Its working for my case. You have to maintain the same size of the button and image....
    Jajal Mehul

  7. #7
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Quote Originally Posted by prajna123 View Post
    imagedisplay.scaledToHeight(88);
    imagedisplay.scaledToWidth(88);
    Remember: QPixmap::scaledToHeight(),QPixmap::scaledToWidth(),and QPixmap::scaled() method will not scale your exising QPixmap. It will return a new QPixmap with scaled value.

    So you can try something like.

    Code:
    QPixmap imagedisplay(NextImagepath);
    QPixmap scaledImage(imagedisplay.scaled(QSize(88,88)));
    QIcon icon(scaledImage);
    Or

    Code:
    QPixmap imagedisplay(NextImagepath);
    QIcon icon(imagedisplay.scaled(QSize(88,88)));
    Hope this might help you.

  8. #8
    Registered User prajna123's Avatar
    Join Date
    Jan 2008
    Posts
    48
    Thanks a lot.
    Below code worked for me.

    QPixmap imagedisplay(NextImagepath);
    QIcon icon(imagedisplay.scaled(QSize(88,88)));

  9. #9
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Also i am Damn sure that first method (suggested in my previous post) will also work.

  10. #10
    Registered User prajna123's Avatar
    Join Date
    Jan 2008
    Posts
    48
    sssssss I checked that also.
    It worked.
    Thank you

  11. #11
    Registered User jayanta_dn's Avatar
    Join Date
    Jul 2011
    Posts
    1
    Dear All,
    I want to share another idea.

    I am using resource files for loading icons. I am trying to resize using the standard setIconSize() method. My problem was the icons were not getting larger, although I was able to shrink them.

    To solve this, I had to open the images in another external image editor, increase the size and then load once again in the resource.

    Look obvious right

Similar Threads

  1. Icons in s60
    By drizzt6 in forum Mobile Java General
    Replies: 5
    Last Post: 2009-03-06, 09:32
  2. Python for S60 1.9.1 released
    By tvijayan in forum Python
    Replies: 30
    Last Post: 2009-02-26, 06:16
  3. size of icon for s60 applicaiton
    By johnmobile in forum General Development Questions
    Replies: 1
    Last Post: 2004-03-17, 01:52
  4. solution: S60 application icon problem
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2002-06-03, 02:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved