Qt 이미지는 QLabel 컨트롤 크기에 맞게 조정됩니다(배율 조정 및 배율 조정).

1433 단어
직접 부호:
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);

좋은 웹페이지 즐겨찾기