Qt 实现QT控件中的QLabel显示图片并自适应显示
程序员文章站
2024-01-19 12:41:22
...
一、需求
实现QT控件中的QLabel显示图片,并自适应显示。
二、代码
QImage Image;
Image.load(":/image/image/logo.jpg");
QPixmap pixmap = QPixmap::fromImage(Image);
int with = ui->label_logo->width();
int height = ui->label_logo->height();
QPixmap fitpixmap = pixmap.scaled(with, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // 饱满填充
//QPixmap fitpixmap = pixmap.scaled(with, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
ui->label_logo->setPixmap(fitpixmap);
上一篇: tensorflow之Eager execution基础
下一篇: [Qt]QLabel的显示圆形
推荐阅读
-
Qt 实现QT控件中的QLabel显示图片并自适应显示
-
qt中,图片自适应QLabel显示
-
Qt——BUG:构造函数中new了控件并隐藏了,后续显示时位置不对?
-
php下将图片以二进制存入mysql数据库中并显示的实现代码
-
C#实现读取DataSet数据并显示在ListView控件中的方法
-
php下将图片以二进制存入mysql数据库中并显示的实现代码
-
如何将服务器中的图片显示出来并实现删除。
-
C#实现读取DataSet数据并显示在ListView控件中的方法
-
php下将图片以二进制存入mysql数据库中并显示的实现代码
-
免费mysql数据库 php下将图片以二进制存入mysql数据库中并显示的实现代码