PDA

View Full Version : QPixmap not getting resized with scaled()



DURGAPRASAD NEELAM
20th March 2014, 08:26
hai, i am resizing the image with scaled function, but it is beeing with the ame size only. i want to decrese size of the image, so that they will take less memory.
i am displaying 1000 images on scene so it is taking more memory because of ths issue. how i have to reduce the sie of Qimage and display them on scene as a thumbnile .




QImage image = tempImage; // is 1025*724
image.scaled(50,50,Qt::KeepAspectRatio);
item = new QGraphicsPixmapItem(QPixmap::fromImage(image));
scene->addItem(item);



after scaling it still the image size is same as old temp image size only.

vikaspachdha
20th March 2014, 08:47
Check the signature of QPixmap::scaled
Its a const method i.e. it will not change the object state. What you need is this :-
.
.
image = image.scaled(50,50,Qt::KeepAspectRatio);
.
.