[英]How to save the image in a resized QLabel?
I have a QLabel that is loaded with a pixmap. 我有一个装有pixmap的QLabel。 I have it set so that when the window/QLlabel is resized, the image of the qlabel resizes as well. 我进行了设置,以便在调整window / QLlabel的大小时,qlabel的图像也随之调整大小。 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? 如何从QLabel检索新调整大小的图像并将其作为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));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.