Qt样式表参考(二)

来源:互联网 发布:tmt行业 知乎 编辑:程序博客网 时间:2024/05/26 05:53
属性列表
下表列出了Qt样式表支持的所有属性.属性值依赖于具体的属性类型。除非指定,否则下面的属性应用于所有的widgets。标记有星号*的属性只适应于Qt并不等价于CSS2或CSS3。


alternate-background-color
Type:Brush  
alternate background c olor在QAbstractItemView的子类中使用。如果这个属性没有被设置,默认值被设置为QPalette::AlternateBase。
background
Type:Background
设置背景的简化符号。相当于指定background-color,backgound-image,background-position.QAstractItemView,QAbstractSpinBox,QCheckBox,QComboBox,QDialog,QFrame,QGroupBox,QLabel,QLineEdit,QMenu,QMenuBar,QPushButton,QRadioButton,QSplitter,QTextEdit,QToolTip,或者简单的QWidgets.例如QTextEdit{background:yellow}
通常它被设置为类似于Qt::BrushStyle样式的填充模式。你可以使用background-color属性Qt::SolidPattern,Qt::RadioGradientPattern,Qt::LinearGradientPattern和Qt::ConicalGradientPattern.其他模式很容易达到通过创建包含该模式的背景图片。例子:QLabel{ background:image: url(dense6pattern.png);background-repeat: repeat-xy;}
background-color
Type:Brush
用来设置widget的背景色。QLabel{background-color:yellow}QLineEdit{background-color:rgb(255,0,0);}
background-iamge
Type:Url
被用于widget的背景图片。图片的半透明部分让background-color显现。
background-repeat
Type:Repeat
是否以及如何用background-image填满background-origin矩形。如果这个属性没有被指定。background-image将在X,Y上同时重复。
QFrame{
background: white url(:/images/ring.png);
background-repeate:repeate-y;
background-position:left;
}
background-position
Type:Alignment
背景图片在background-origin矩形的对其方式.如果这个属性没有被指定,默认是左上
QFrame{
background:url{:/image/footer.png};
background-position:bottom left;
}
background-attachment
Type:Attachment
决定背景图片相对于视窗是否被固定。默认是随视窗滚动的。
QTextEdit{
background-image:url{"leaves.png"};
background-attachment:fixed;
}
background-clip
Type:Origin
这个属性指定矩形框,backgound-color和background-image被裁剪。
如果这个属性没有被指定默认是border.
QFrame{
background-iamge:url(:/image/header.png);
background-position:top left;
background-origin:content;
background-clip:padding;
}
background-origin
Type:Origin
widget的背景矩形使用background-position和background-image来链接。如果没有指定默认是padding
QFrame{
background-image:url(:/image/header.png);
background-position:top,left;
background-origin:content;
}
border
Type:Border
为了widget的border简写。等价于border-color和border-style或者border-width.QLineEdit{ border:1px solid white}
border-top
Type:Border
widgets的 top border简写。等价于指定border-top-color,border-top-style,border-top-width.
border-right
Type:Border
widgets的 right border简写。等价于指定border-right-color,border-right-style,border-right-width.
border-bottom
Type:Border
widgets的 bottom border简写。等价于指定border-bottom-color,border-bottom-style,border-bottom-width.
border-left
Type:Border
widgets的 left border简写。等价于指定border-left-color,border-left-style,border-left-width.
border-color
Type:Box Color
所有border边界的颜色。等价于指定border-top-color,border-right-color,border-bottom-color,border-left-color.如果这个属性没有被指定,它默认是widgets的前景色。
border-top-color
border-right-color
border-bottom-color
border-left-color
border-image
Type:Border Image
image通常填充border。image被裁剪或者适当拉伸如果需要的话。
border-radius
Type:Radius
border边角的半径。等价于指定border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius.border-radius裁剪的是元素的背景。
QLineEdit {
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
}
border-top-left-radius
border-top-right-radius
border-bottom-left-radius
border-bottom-right-radius
border-style
Type:Border Style
所有border边界的风格。如果没有被指定默认是none
QLineEdit {
    border-width: 1px;
    border-style: solid;
    border-color: blue;
}
border-top-style
border-left-style
border-right-style
border-bottom-style
border-width
Type:Box Lengths
border的宽度。等价于设置border-top-width,border-right-width,border-bottom-width和border-left-width.
QLineEdit {
    border-width: 2px;
    border-style: solid;
    border-color: darkblue;
}
border-top-width
border-right-width
border-bottom-width
border-left-width
bottom
Type:Length
如果位置是相对的,通过移动一个确定偏移量的子控制器。指定bottom:y等价于指定top:-y.如果是绝对位置,bottom属性指定一个子控制器的bottom边界相对于父窗体的bottom边界。QSpinBox::down-button{bottom:2px}
button-layout
Type:Number
在QDialogButtonBox或者QMessageBoxbuttons的布局。可能的值是0,1,2,3。如果这个值没有被指定,它默认值是SH_DialogButtonLayout.
color
Type:Brush
color为text着色。如果没有被指定默认是QWidget::foregroundRole
dialogbuttonbox-buttons-have-icons
Type:Boolean
QDialogButtonBox的buttons是否展示图标。如果属性被设置为1则展示,否则不展示。
font
Type:Font
设置文本字体的简写等价于font-family,font-size,font-style,font-weight.
font-family
Type:String
QCheckBox { font-family: "New Century Schoolbook" }
font-size
Type:Font Size
字体大小,这个版本的Qt(5.5.0)只支持pt和px。
font-style
Type:Font Style 
QTextEdit{font-style:italic}
font-weight
Type:Font Weight
gridline-color*
Type:Color
QTableView的网格线的颜色。如果这个属性没有被指定默认值依赖于子控制器和当前的风格。
height
Type:Length
子控制器的高度,如果这个属性没有呗指定则依赖于subcontrol/widget和当前的风格。
icon-size
Type:Length
icon的宽度和高度。支持这个属性的类QCheckBox,QListView,QPushButton,QRadioButton,QTabBar,QToolBar,QToolBox,QTreeView.
image*
Type:Url+
image被绘制在subcontrol的content矩形里。在子控制器上设置image属性隐含的设置了子控制器的width和height.
image-position
Type:alignment
在Qt4.3和之后的版本,image的对齐方式和位置可以使用相对或者绝对位置指定。
left
Type:Length
如果位置是相对的(默认),向右移动某一偏移量的距离。
如果位置是绝对的,left属性指定子控制器的left边界相对于父窗口的左边界。
lineedit-password-character*
Type:Number
QLineEdit密码字符,如果没有被指定默认是SH_LineEdit_PasswordCharacter.
lineedit-password-mask-delay*
Type:Number
密码由字符转变为密码字符的延迟的秒数。
margin
Type:Box Lengths
widget的margin.等级爱与指定margin-top,margin-right,margin-bottom,margin-left
如果属性没有被指定默认是0
margin-top
margin-right
margin-bottom
margin-left
max-height
Type:Length
widget子控制器的最大高度。这个值是相对于content矩形的。
max-width
Type:Length
widget或者subcontrol的最大宽度。
messagebox-text-interaction-flags*
Type:Number
messageBox文本的交互行为。可能的值基于Qt::TextInteractionFlags。如果属性没有被指定,默认指定为SH_MessageBox_TextInteractionFlags。
min-height
Type:Length
widget或者subcontrol的最小高度。如果没有被指定,最小高度基于widget的content和风格。
min-width
Type:Length
widget或者subcontrol的最小宽度
如果属性没有被指定,最小宽度基于widget的content和风格。
opacity*
Type:Number
widget的透明度,可能的值是0-255.目前只支持tooltips如果这个属性没有被指定它默认值是SH_ToolTipLabel_Opacity。
padding
Type:Box Length
widget的padding等价于padding-top,padding-right,padding-bottom,padding-left.
如果属性没有被指定默认是0
padding-top
padding-right
padding-left
padding-bottom
paint-alternating-row-colors-for-empty-area
Type:bool
QTreeView是否为空白区域绘画可替代行的颜色。
position
Type:relative | absolute
left,right,top,bottom是相对坐标还是绝对坐标。
right
Type:Length
如果是相对位置,子控制器向左移动某个偏移量。如果是绝对位置,right属性指定子控制器的right边界相对于父窗体的右边界。
selection-background-color*
Type:Brush
选中text和item的背景色。如果这个值没有被设置,将被palette的HighlightedText角色设置。
selection-color*
Type:Brush
选中text和item的前景色。如果这个值没有被设置,将被palette的HighlightedText角色设置。
show-decoration-selected*
Type:Boolean
控制QListView选中覆盖整行还是只覆盖文本。
spacing*
Type:Length
如果这个属性没有被指定默认值依赖于widget和当前风格。
subcontrol-origin*
Type:Origin
子控制器的origin矩形。没有被指定默认是padding.
subcontrol-position*
Type:Alignment
在origin矩形内子控制器的对其方式。
text-align
Type:Alignment
text和icon的对其方式。
text-decoration
Type:none underline overline line-through
附加的文本效果
top
Type:Length
position relative and absolute
width:Length
position relative and absolute
0 0
原创粉丝点击