直接上代码:
QImage Image;
Image.load("d:/test.jpg");
QPixmap pixmap = QPixmap::fromImage(Image);
int with = ui->labPic->width();
int height = ui->labPic->height();
QPixmap fitpixmap = pixmap.scaled(with, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // 饱满填充
//QPixmap fitpixmap = pixmap.scaled(with, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
ui->labPic->setPixmap(fitpixmap);
Qt中图片加载与显示
本文介绍如何使用Qt进行图片的加载与显示,包括利用QImage和QPixmap处理图片,并调整图片大小以适应指定控件。
3125

被折叠的 条评论
为什么被折叠?



