1

I have a QLabel that is loaded with a pixmap. I have it set so that when the window/QLlabel is resized, the image of the qlabel resizes as well. However, when I try to save the image and retrieve the pixmap, it is the original loaded. How would I go about retrieving the newly resized image from the QLabel and retrieving it as a QImage?

carboncomputed
  • 1,630
  • 3
  • 20
  • 42

1 Answers1

1

On the resize event of your label, Use

Label->setPixmap(QPixmap::fromImage(YourImage).scaled(ui->Label->size(), Qt::IgnoreAspectRatio));

For getting image as size of image use

Label->pixmap().toImage();

if this image is still not the same size as of label, Try

Label->pixmap().toImage().scaled(Label->size(), Qt::IgnoreAspectRatio));
ScarCode
  • 3,074
  • 3
  • 19
  • 32
  • 2
    pixmap in label will be same. QLabel doesn't modify pixmap itself it only renders it scaled. Third way will work. – Kamil Klimek May 23 '12 at 08:22