Qt中的Label和PushButton背景图自动缩放设置
- Label 背景图自动缩放
QPixmap* pixmap = new QPixmap(":/images/HeadIcon/1.png");
pixmap->scaled(ui->label->size(),Qt::KeepAspectRatio);
ui->label->setScaledContents(true);
ui->label->setPixmap(*pixmap);
- PushButton 背景图自动缩放
ui->pushButton->setStyleSheet("border-image: url(:/images/HeadIcon/2.png);");