加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

qt的stylesheet中如何设置属性使背景图自动调整来适应控件的大小

(2017-02-09 09:51:15)
标签:

qt

widget背景自适应

分类: VC Qt

A background-image does not scale with the size of the widget. To provide a "skin" or background that scales along with the widget size, one must use border-image. Since the border-image property provides an alternate background, it is not required to specify a background-image when border-image is specified. In the case, when both of them are specified, the border-image draws over the background-image.

默认background-image 不会缩放图片以适应控件的大小。
如果要提供一个皮肤或背景图片以自动适应控件大小,
必须也只能用border-image属性。
因为border-image已经设置了可用的背景图片,
所以使用了border-image后,没必要再指定background-image。

 

 

 


如果同时指定了两个属性,那么将会使用border-image 绘制覆盖掉background-image。

例子中的
QMainWindow > .QWidget {
    background-color: gainsboro;
    background-image: url(:/images/pagefold.png);
    background-position: top right;
    background-repeat: no-repeat
}

把上面的改成:
QMainWindow > .QWidget {
    background-color: gainsboro;
    border-image: url(:/images/pagefold.png);
}
就能实现你要的效果了,自动将pagefold.png拉伸填满整个背景。

 

原地址:http://blog.csdn.net/dyzhen/article/details/44995049

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有