1 QPixmap pixmap(path); 2 //pixmap=QPixmap::fromImage(imgShow); 3 pixmap = pixmap.scaled(152, 76, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放 4 ui->logo->setPixmap(pixmap);
fromImage可以将QImage转换为QPixmap.scaled可以实现等比缩放