简体   繁体   中英

How to save the image in a resized QLabel?

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?

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM