PDA

View Full Version : Pixmap scaling problem



tommy
14th May 2009, 17:52
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.



//declare and make pixmap
QPixmap map(600,400);
map.fill(Qt::white);

//save pixmap
map.save("pic.bmp", 0, -1);

//scale and display pixmap
map=map.scaled(300, 200, Qt::IgnoreAspectRatio, Qt::FastTransformation);
pixmapLabel->setPixmap(map);

aamer4yu
14th May 2009, 18:00
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.