直接上代码:

1 QImage Image;
2     Image.load("d:/test.jpg");
3     QPixmap pixmap = QPixmap::fromImage(Image);
4     int with = ui->labPic->width();
5     int height = ui->labPic->height();
6     QPixmap fitpixmap = pixmap.scaled(with, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);  // 饱满填充
7     //QPixmap fitpixmap = pixmap.scaled(with, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 按比例缩放
8     ui->labPic->setPixmap(fitpixmap);

 

相关文章:

  • 2021-10-01
  • 2022-01-18
  • 2021-11-28
  • 2021-09-14
  • 2021-07-05
  • 2021-07-19
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-01-16
相关资源
相似解决方案