Results 1 to 2 of 2

Thread: Pixmap scaling problem

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Pixmap scaling problem

    I have a program that operates with larger images but displays smaller versions of these images. I cannot get the scaling to work properly, the result is always too large. Below is my code. Thanks.

    Qt Code:
    1. //declare and make pixmap
    2. QPixmap map(600,400);
    3. map.fill(Qt::white);
    4.  
    5. //save pixmap
    6. map.save("pic.bmp", 0, -1);
    7.  
    8. //scale and display pixmap
    9. map=map.scaled(300, 200, Qt::IgnoreAspectRatio, Qt::FastTransformation);
    10. pixmapLabel->setPixmap(map);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pixmap scaling problem

    I cannot get the scaling to work properly, the result is always too large.
    What do you mean by that ? May be your label scales according to layout/ main window and hence you get larger pic.

    Try setting size constraint on layout. Or you can try scaledToContents of QLabel.

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

    tommy (14th May 2009)

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2009, 10:05
  2. Drag pixmap on Windows size problem
    By plamkata in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 00:01
  3. experiencing problem at printing out QTableWidget
    By rmagro in forum Qt Programming
    Replies: 9
    Last Post: 27th June 2007, 17:04
  4. Rotation problem trying to draw a compass widget
    By yellowmat in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2007, 20:03
  5. Replies: 10
    Last Post: 1st February 2006, 11:08

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.