Qt QSS中 background-image,border-image,以及image属性差别
admin
2024-02-24 13:58:54
0次

background-image:

qt中the style reference中介绍:
        The background image used for the widget. Semi-transparent parts of the image let the background-color shine through.Example:
        Whether and how the background image is repeated to fill the background-origin rectangle.If this property is not specified, the background image is repeated in both directions (repeat).
Example:
        指定部件背景,填充背景方式受background-repeat方式影响,如果图片过小,将会图片裁剪填充其他区域;过大,截取一部分区域填充。


border-image:


qt中the style reference中介绍:
        The image used to fill the border. The image is cut into nine parts and stretched appropriately if necessary. See Border Image for details
        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用来填充部件的border区域,border-image会被分割成9部分,已边拉伸适应部件的border区域,一般来说,设置部件的背景,最好使用该属性,会自适应部件区域大小。


image:


qt中the style reference中介绍:
        The image that is drawn in the contents rectangle of a subcontrol.The image property accepts a list of Urls or an svg. The actual image that is drawn is determined using the same algorithm as QIcon (i.e) the image is never scaled up but always scaled down if necessary. If a svg is specified, the image is scaled to the size of the contents rectangle.
Setting the image property on sub controls implicitly sets the width and height of the sub-control (unless the image in a SVG).
In Qt 4.3 and later, the alignment of the image within the rectangle can be specified using image-position.
This property is for subcontrols only--we don't support it for other elements.
意思:
        image用来绘制子控件的内容(content)区域,iamge只能缩小,不能放大,与设置QIcon表现一样。
        例如Qcheckbox中有indictor控件,indictor子控件背景图片样式可以这样设置:
QCheckBox::indicator:unchecked {
     image: url(:/images/checkbox_unchecked.png);
 }

相关内容

热门资讯

中国超算再夺世界第一,祝贺!中... 当地时间11月17日,在美国芝加哥举行的SC26国际超级计算大会期间,新一期全球超算TOP500榜单...
伯克希尔最新调仓 增持地产与航... 美东时间11月16日,伯克希尔·哈撒韦向美国证监会提交了2026年三季度的13F持仓文件。文件显示,...
高速窜出老虎车辆紧急避让!司机... 吉林延边一位网友在高速路上差点撞上野生东北虎。目击者石先生表示,虽然之前见过东北虎,但在高速公路上遇...
北航硕士回应399元北大羽绒服... 北航硕士回应399元北大羽绒服卖断货 名校情怀引热潮。北京大学新款羽绒服定价399元,鹅绒填充、绒子...
女子借给闺蜜4万元后引来杀身之... 2026年11月10日上午10点,四川泸州市中级人民法院门外,年近40岁的黄平抱着母亲吴小萍(化名)...
中国人寿割肉“易中天” 险资被... 中国人寿割肉“易中天” 险资被迫财务止损。11月16日,A股算力板块的“定海神针”彻底失灵。光模块三...
胖东来洗发水关联方曾多次被罚 ... 胖东来洗发水关联方曾多次被罚 涉假洋牌争议。近日,胖东来售卖的卡蓓诺洗发水引发了争议。有网友发布视频...
曾毓群:将电动化应用拓展至海洋... 曾毓群:将电动化应用拓展至海洋天空 创新引领未来方向!11月17日,来自亚太经合组织21个经济体及英...
首饰金价格跌破每克千元关口 金... 首饰金价格跌破每克千元关口。近期国际金价持续走弱,导致国内金饰零售价快速下降。11月12日,国内主流...
APEC背后的中国变化 中国力... APEC为何离不开中国力量?广东又如何成为亚太合作的窗口?11月16日,南都N视频推出《APEC背后...
老药工30年守护一株钻山风 传... 老药工30年守护一株钻山风。在河南新密,老药工马伟国用三十年时间默默守护着一株珍贵的钻山风。这种药材...
日本老年人陷入“带病工作”困境... 日本老年人陷入“带病工作”困境 养老金不足加剧问题。日本是一个高度老龄化的国家,与我们这边有所不同。...
亚马尔事件反转,央视发文:西甲... 11月16日,有媒体报道称,西甲巴塞罗那俱乐部球员亚马尔在个人社交平台账号转发一条短视频,因该视频含...
DeepSeek对App与网页... 据报道,DeepSeek 对其应用程序和网页版的长对话功能实施了使用限额。用户收到提示称,由于算力不...
中央气象台发布大风蓝色预警 多... 预计11月17日08时至18日08时,青海北部、甘肃大部、内蒙古大部、宁夏、陕西北部、山西、河北北部...
景区招保洁参照公务员体检标准 ... 景区招保洁参照公务员体检标准!近日,某景区招聘53名派遣保洁人员的消息引起了关注。招聘信息显示,应聘...
氯化铵市场年内罕见快速上涨 创... 氯化铵市场正经历一轮年内罕见的快速上涨。截至11月16日,氯化铵工业级价格达到730元/吨,创下年内...
19岁留学生在泰被成功解救 警... 泰国警方于11月14日在芭提雅一家酒店内找到一名19岁的中国留学生,所幸他身体没有受到伤害。此前,有...
女子在KTV电梯内遭陌生男子搂... 11月11日晚上11点,海口一名年轻女子走进KTV电梯,准备去三楼找朋友唱歌。她全程没沾过酒,脑子清...
凯特患癌后首次陪同威廉出访 抗... 凯特患癌后首次陪同威廉出访。2024年3月,凯特王妃证实自己得了癌症,正在接受预防性化疗。同年9月,...