添加一个图片,改变图片大小,适应label
Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); QPixmap map("C:/Users/Administrator/Desktop/123.png"); ui->label->setPixmap(map); ui->label->resize(map.width(),map.height()); }
缩放图片,适应标签大小
Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); QPixmap map("C:/Users/Administrator/Desktop/123.png"); ui->label->setPixmap(map); ui->label->setScaledContents(true); }