Results 1 to 4 of 4

Thread: Pixmap scaling

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Pixmap scaling

    Hi everybody,

    I want to display an image (.png) over a QPushButton object in order to customize its look.

    My png file has a size bigger than my button's so what I am trying to do is scaling down my image size to the button's size and then display the image over my button.

    The problem is that my pixmap is never scalled to the button's size and I don't understand why, so if somebody could help me it would be great.

    Here is my code :
    Qt Code:
    1.  
    2. QImage img;
    3. img.resize(90, 24);
    4. img.load("play.png");
    5. img.scale(90, 24);
    6.  
    7. QPixmap pix;
    8. pix.convertFromImage(img);
    9.  
    10. but.setPixmap(pix);
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance

  2. #2
    Join Date
    Jun 2006
    Location
    Arizona
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pixmap scaling

    Greetings,
    In your code, you had:

    img.scale( 90, 24 );

    surely, you meant
    img.scaled( 90, 24 );

    the shorthand of your code would look like this:

    QPushButton but;
    QPixmap pixmap( "Play.png" );
    but.setPixmap( pixmap.scaled(90,24) );

    It is not necessary to start out as a QImage.

    Larry
    Larry Dobson

    If you want to be seen... stand up
    If you want to be heard... speak up
    If you want to be respected... shut up

  3. #3
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Pixmap scaling

    I'm sorry but there is no function named "scaled" in Qt3 that I can call from WImage, neither QPixmap so your solution does not work for me

  4. #4
    Join Date
    Jun 2006
    Location
    Arizona
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pixmap scaling

    Oops. My bad. Didn't notice the Qt3 qualifier.
    Larry Dobson

    If you want to be seen... stand up
    If you want to be heard... speak up
    If you want to be respected... shut up

Similar Threads

  1. load pixmap from another host
    By raphaelf in forum Newbie
    Replies: 16
    Last Post: 31st August 2006, 22:58
  2. Invalid pixmap
    By munna in forum Newbie
    Replies: 2
    Last Post: 8th June 2006, 08:00
  3. Replies: 12
    Last Post: 25th May 2006, 21:12
  4. Paint XP radio button to pixmap
    By Ben.Hines in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2006, 21:15
  5. Changing pixmap in PixmapLabel
    By bullerwj in forum Qt Tools
    Replies: 1
    Last Post: 11th April 2006, 22:28

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.