Qt第五十一章:Qt样式表-Qss

目录

一、盒子模型

二、选择器

三、伪状态

四、字体

五、边框

六、背景

七、边距

八、示例大全


一、盒子模型

二、选择器

选择器示例描述
通用选择器*匹配所有控件
类型选择器QPushButton匹配给定类型控件,包括子类
类选择器.QPushButton匹配给定类型控件,不包括子类
属性选择器QPushButton[flat=“false”]匹配给定类型控件中符合[属性]的控件
ID选择器QPushButton#button_close匹配给定类型,且对象名为button_close的控件
子对象选择器QDialog>QPushButton匹配给定类型的直接子控件
子孙对象选择器QDialog QPushButton匹配给定类型的子孙控件
辅助(子控件)选择器QComboBox::drop-down复杂对象的子控件
伪状态选择器QPushButton:hover控件的特定状态下的样式
多选择器

QPushButton#button_send_captcha:hover,

QPushButton#button_register:hover

{
    color: rgb(65, 65, 65);
}

多个选择器取并集,用逗号隔开

三、伪状态

状态描述
:disabled控件禁用
:enabled控件启用
:focus控件获取输入焦点
:hover鼠标在空间上悬停
:pressed鼠标按下
:checked控件被选中
:unchecked控件没有选中
:indeterminate控件部分被选中
:open控件打开
:closed控件关闭
:on控件可以切换,且处于on状态
:off控件可以切换,且处于off状态
!对以上状态的非状态

四、字体

属性示例描述
font-familyfont-family: 楷体, serif; 字体类型
font-sizefont-size: 18px;字体大小
font-stylefont-style:italic;

字体风格

italic 为斜体

normal 为不斜体

font-weightfont-weight: bold;

字体加粗

bold 为加粗

normal 为不加粗

colorcolor:rgba(255,100,0,100%);字体颜色
letter-spacingletter-spacing: 10px;字间距
line-heightline-height: 50px;行高

五、边框

属性示例描述
border-styleborder-style: solid;

边框风格:

无边框none、点状dotted、虚线dashed、实线solid、

双线double、3d凹槽groove、3d垄状ridge、3d内嵌inset、

3d外嵌outset、父样式inherit

border-widthborder-width: 2px;边框宽度
border-colorborder-color: blue;边框颜色
border-radiusborder-radius: 10px;边框圆角
border-top-widthborder-top-width: 2px;顶部边框的宽度
border-top-left-radiusborder-top-left-radius: 10px;左上角圆角
border-left-colorborder-left-color: blue;左边框颜色

六、背景

属性示例描述
background-color

background-color: rgb(232, 248, 78);

background-color: transparent;透视

背景颜色
background-imagebackground-image: url("./image.png");背景图片
background-repeatbackground-repeat: no-repeat;

no-repeat 不重复

repeat-x 在x轴重复

repeat-y 在y轴重复

background-positionbackground-position: left center;

显示位置

left right top bottom center;

left right center 水平位置,

top bottom center 垂直位置

min-width: 100px;min-width: 100px;最小宽度
max-widthmax-width: 400px;最大宽度
min-heightmin-height: 20px;最小高度
max-heightmax-height: 50px;最大高度

七、边距

属性示例描述
padding-toppadding-top:10px;内边距-上边距
padding-leftpadding-left:10px;内边距-左边距
padding-rightpadding-right:10px;内边距-右边距
padding-bottompadding-bottom:10px;内边距-下边距
margin-topmargin-top:10px;外边距-上边距
margin-rightmargin-right:10px;外边距-右边距
margin-bottommargin-bottom:10px;    外边距-下边距
margin-leftmargin-left:10px;外边距-左边距

八、示例大全

Qt css样式大全(整理版)_xiao_-_zhu的博客-CSDN博客_qt如何批量设置css字体属性:(font)大小 {font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)行高 {line-height: normal;}(正常) 单位:PX、PD、EM粗细 {font-whttps://blog.csdn.net/u013968786/article/details/51295744

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

文子阳

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

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

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

打赏作者

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

抵扣说明:

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

余额充值