当前位置: 首页 > 工具软件 > image > 使用案例 >

image、border-image、background-image的区别

陈畅
2023-12-01

Qt 设置样式表 加载图片时

  • //背景 不会自动适应图片,background-image像电脑桌面的平铺,图片尺寸不变
  • setStyleSheet(QString("background-image:url(:/image/test.jpg)"));
  • //背景 自动适应图片,border-image像桌面的拉伸效果,常用
  • setStyleSheet(QString("border-image:url(:/image/test.jpg);"));
  • //前景 自动适应图片,border-image像桌面的拉伸效果,常用
  • setStyleSheet(QString("image:url(:/image/test.jpg);"));

QCustomplot背景自适应  拉伸

 ui->customPlot->setBackground(QPixmap(":/image/error.png"),true,Qt::KeepAspectRatioByExpanding);

QCustomplot背景默认不拉伸

v ui->customPlot->setBackground(QPixmap(":/image/error.png")); 

 

 类似资料: