项目列表
| Qt样式单参考 |
| 可进行样式设置的部件列表 |
| 属性列表 |
| 图标列表 |
| 属性类型列表 |
| 伪状态列表 |
| 子控件列表 |
请在py文件进行调用
Home · All Classes · Modules · QSS HELP · QSS 案例 · VER007 HOME
Qt4.7文档翻译:Qt样式单参考,Qt Style Sheets Reference
属性类型 来进行赋值。除非另外有说明,否则以下的属性对所有部件都有用。带有星号*的属性是Qt 特有的,在CSS2 或CSS3 中没有等价属性。
- • QCheckBox
- • QListView
- • QPushButton
- • QRadioButton
- • QTabBar
- • QToolBar
- • QToolBox
- • QTreeView
|
| image | Url+ | 被绘制到一個子控件( subcontrol)的内容区域的图片。image(图片)属性接受一组 Url(统一资源定位器)或一個svg(可缩放矢量图)。实际绘制的图片是由与 QIcon相同的算法来确定的,(也就是说)图片绝不会被放大但必要的时候一定会缩小。如果指定咯一個svg,则图片会缩放到内容区域的大小。在子控件上设置图片会隐式地设置那個子控件的宽度和高度(除非图片是一個SVG)。在Qt 4.3 和以后的版本中,可使用 image-position来指定图片在矩形区域中的对齐方式。这個属性是只为子控件( subcontrol)设计的—我们不在其它元素中支持它。警告:需要有QIcon SVG 插件才能渲染SVG 图片。示例:/ 隐式地将down-button 的大小设置成spindown.png 的大小 /QSpinBox::down-button { image: url(:/../img/spindown.png) } |
| image-position | alignme nt | 在Qt 4.3 及以后的版本中,图片的位置可使用相对定位和绝对定位来设置。 |
| left | Length | 如果 position(位置)是relative(相对的)(默认值),则将某個 subcontrol(子控件)向右移动一定距离。如果 position是absolute(绝对的),则left属性指定的是这個子控件的左边线与亲代部件的左边线的相对位置(参考 subcontrol-origin)。如果没有设置,则默认值是0。示例:QSpinBox::down-button { left: 2px }参考 right、 top和 bottom。 |
| lineedit-password-character | Number | 以Unicode(统一码)指定的 QLineEdit密码字符。如果这個属性没有设置,则默认值是由当前风格中的SH_LineEdit_PasswordCharacter样式提示确定的。示例: { lineedit-password-character: 9679 } |
| margin | Box Lengths | 部件的边距(margins)。等价于指定margin-top、margin-right、margin-bottom和margin-left。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、 QLineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSplitter、 QTextEdit和 QToolTip支持。如果没有设置的话,默认为0。示例:QLineEdit { margin: 2px }参考 padding、 spacing和盒状模型。 |
| margin-top | Length | 部件的顶部边距。 |
| margin-right | Length | 部件的右侧边距。 |
| margin-bottom | Length | 部件的底部边距。 |
| margin-left | Length | 部件的左侧边距。 |
| max-height | Length | 这個部件或者其子控件的最大高度。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、 QLineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSizeGrip、 QSpinBox、 QSplitter、 QStatusBar、 QTextEdit和 QToolTip支持。这個值是相对于盒状模型中的内容区域的。示例:QSpinBox { max-height: 24px }参考 max-width。 |
| max-width | Length | 这個部件或者其子控件的最大宽度。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、 QLineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSizeGrip、 QSpinBox、 QSplitter、 QStatusBar、 QTextEdit和 QToolTip支持。这個值是相对于盒状模型中的内容区域的。示例:QComboBox { max-width: 72px }参考 max-height。 |
| messagebox-text-interaction-flags | Number | 在消息框中的文字的交互行为。可能取的值取决于Qt::TextInteractionFlags。如果属性没有设置的话,则默认值是由当前风格中的SHMessageBox_TextInteractionFlags样式提示确定的。示例:QMessageBox { messagebox-text-interaction-flags: 5 } |
| min-height | [Length](docs#length) | 这個部件或者其子控件的最小高度。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、 QLineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSizeGrip、 QSpinBox、 QSplitter、 QStatusBar、 QTextEdit和 QToolTip支持。如果这個属性没有指定的话,则最小高度是基于这個部件的内容和样式来继承的。这個值是相对于盒状模型中的内容区域的。示例:QComboBox { min-height: 24px }参考 min-width。 |
| min-width | Length | 这個部件或者其子控件的最小宽度。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、Q LineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSizeGrip、 QSpinBox、 QSplitter、 QStatusBar、 QTextEdit和 QToolTip支持。如果这個属性没有指定的话,则最小宽度是基于这個部件的内容和样式来继承的。这個值是相对于盒状模型中的内容区域的。示例:QComboBox { min-width: 72px }参考 min-height。 |
| opacity | Number | 某個部件的透明度。取值范围从0 (透明)到255 (不透明)。当前只被工具提示( tooltips)支持。如果这個属性没有设置,则默认值由当前风格中的SHToolTipLabel_Opacity样式提示确定。示例:QToolTip { opacity: 223 } |
| padding | [Box](docs#box-lengths) Lengths | 这個部件的填充宽度(padding)。等价于设置padding-top、padding-right、padding-bottom和padding-left。这個属性被 QAbstractItemView子类、 QAbstractSpinBox子类、 QCheckBox、 QComboBox、 QFrame、 QGroupBox、 QLabel、 QLineEdit、 QMenu、 QMenuBar、 QPushButton、 QRadioButton、 QSplitter、 QTextEdit和 QToolTip支持。如果没有设置的话,默认为0。示例:QLineEdit { padding: 3px }参考 margin、 spacing和盒状模型。 |
| padding-top | Length | 这個部件的顶部填充距离。 |
| padding-right | Length | 这個部件的右侧填充距离。 |
| padding-bottom | Length | 这個部件的底部填充距离。 |
| padding-left | Length | 这個部件的左侧填充距离。 |
| paint-alternating-row-colors-for-empty-area | bool | QTreeView是否要为空白区域(没有条目的区域)绘制交替行颜色 |
| position | relative
| absolute | 用 left、 right、 top和 bottom指定的偏移值是相对的还是绝对的坐标。如果没有设置,则默认值是relative。 |
| right | Length | 如果 position(位置)是relative(相对的)(默认值),则将某個 subcontrol(子控件)向左移动一定距离;在那种情况下,指定right: x就等价于指定 left : - x。如果 position是absolute(绝对的),则right属性指定的是这個子控件的右边线相对于亲代部件的右边线的位置(参考 subcontrol-origin)。示例:QSpinBox::down-button { right: 2px }参考 left、 top和 bottom。 |
| selection-background-color | Brush | 选中的文字或条目的背景。所有支持QWidget::palette并且显示选中文字的部件都支持这個属性。如果没有设置,则默认值是为调色板的Highlight角色设置的值。示例:QTextEdit { selection-background-color: darkblue }参考 selection-color和 background。 |
| selection-color | Brush | 选中的文字或条目的前景。所有支持QWidget::palette并且显示选中文字的部件都支持这個属性。如果没有设置,则默认值是为调色板的HighlightedText角色设置的值。示例:QTextEdit { selection-color: white }参考 selection-background-color和 color。 |
| show-decoration-selected | Boolean | 控制的是在一個 QListView中的选中区域是要覆盖整个行还是只覆盖文字的区域。如果没有设置,则默认值是由当前风格中的SH_ItemView_ShowDecorationSelected样式提示确定的。示例: { show-decoration-selected: 1 } |
| spacing | Length | 这個部件内部的间隔(spacing)。这個属性被 QCheckBox、可选中的 QGroupBox、 QMenuBar和 QRadioButton支持。如果没有指定,则默认值取决于部件本身及当前风格。示例:QMenuBar { spacing: 10 }参考 padding和 margin。 |
| subcontrol-origin | Origin | 这個 subcontrol(子控件)在亲代元素中的根源(origin)矩形。如果没有指定,则默认值为padding。示例:QSpinBox::up-button {image: url(:/../img/spinup.png);subcontrol-origin: content;subcontrol-position: right top;}参考 subcontrol-position。 |
| subcontrol-position | Alignment | 这個子控件( subcontrol)在由 subcontrol-origin确定的根源矩形中的对齐方式。如果没有设置的话,则默认值取决于子控件本身。示例:QSpinBox::down-button {image: url(:/../img/spindown.png);subcontrol-origin: padding;subcontrol-position: right bottom;}参考 subcontrol-origin。 |
| text-align | Alignment | 文字和图标在这個部件的内容中的对齐方式。如果没有设置的话,则默认值取决于原生(native)风格。示例:QPushButton {text-align: left;}当前只有 QPushButton和 QProgressBar支持这個属性。 |
| text-decoration | none
underline
overline
line-through | 附加的文字效果 |
| top | Length | 如果 position是relative(相对的)(默认值),则将一個 subcontrol(子控件)向下移动指定距离。如果 position是absolute(绝对的),则top属性指定的是这個子控件的顶部边线相对于亲代部件的顶部边线的位置(参考 subcontrol-origin)。如果没有设置的话,则默认值是0。示例:QSpinBox::up-button { top: 2px }参考 left、 right和 bottom。 |
| width | Length | 一個 subcontrol(子控件)(或者在某些情况下会是部件)的宽度。如果没有设置的话,则默认值取决于子控件/部件本身及当前的风格。警告:除非另外说明,否则这個属性对于部件无效。如果妳想让某個部件具有固定的宽度,则将 min-width和 max-width设置成相同的值。示例:QSpinBox::up-button { width: 12px }参考 height。 |
Icon 。
注意,要想让 QDialogButtonBox 中的按钮里出现图标的话,妳需要将dialogbuttonbox-buttons-have-icons 属性设置成true(真)。并且,要对图标的尺寸进行自定义的话,则使用icon-size 属性。