Qt 显示图片

QImage qImag("img.jpg");  

//qImag = qImag.scaled(width, height);  //缩放图片
qImag = qImag.scaled(ui.label_img->size());

ui.label_img->setPixmap(QPixmap::fromImage(qImag));
QFile file("img.jpg");
file.open(QIODevice::ReadOnly);
QByteArray t = file.readAll();

QImage qImag;
qImag.loadFromData(t, "jpg");

qImag = qImag.scaled(ui.label_img->size());

ui.label_img->setPixmap(QPixmap::fromImage(qImag));

file.close();
posted @ 2019-09-18 22:25  thomas_blog  阅读(239)  评论(0编辑  收藏  举报