Qt-使用border image填满背景

什么是border image?

A border image is an image that is composed of nine parts (top left, top center, top right, center left, center, center right, bottom left, bottom center, and bottom right). When a border of a certain size is required, the corner parts are used as is, and the top, right, bottom, and left parts are stretched or repeated to produce a border with the desired size.

See the CSS3 Draft Specification for details.

所谓border image是这样一种图片,它由九宫格分成的九个部分组成,当“边”设置了某个长度,角落的四个部分不发生变化,上下左右四个部分则发生一定的拉伸或者重复。

感觉翻译有点问题,看实际效果可能才能更好理解。

参数如下:

none
Url Number{4}
(stretch | repeat){0,2}

下面使用QLabel设置背景来说明,最常用的用法如下,将图片填满控件:

QLabel{
	border-image:url(:/images/Resource/nine.png) 0 0 0 0 stretch strctch
}

此时拉伸Label会使背景图片跟着拉伸

          

 

四个数字相当于上、右、下、左“边”的宽度

四个数字如果是25 30 10 20则对应含义如下:

实际效果比较奇怪,类似于图片某个方向拉伸,如:

QLabel{
	border-image:url(:/images/Resource/nine.png) 50 0 0 0
}

 

不写后面两个参数默认都是stretch。

最后两个参数对应横向和纵向的策略,如:

QLabel{
	border-image:url(:/images/Resource/nine.png) 0 0 0 0 stretch repeat
}

横向拉伸纵向重复。

 

参考:

1.https://doc.qt.io/archives/qt-4.8/stylesheet-reference.html#border-image 

2.https://css-tricks.com/understanding-border-image/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mrbone11

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值