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);");
posted @ 2020-02-23 11:23  WindSun  阅读(904)  评论(0编辑  收藏  举报
博客已停更,文章已转移,点击访问