通用属性列表 - List of Properties
下列表格中的Qt样式表支持所有的Qt控件,除非有特殊声明的,在列表中含有*号的表示和 CSS2 or CSS3有很大区别的属性。
Property | Type | Description |
The alternate background color used in QAbstractItemView subclasses. If this property is not set, the default value is whatever is set for the palette's AlternateBase role. Example: QTreeView { alternate-background-color: blue; background: yellow; } See also background and selection-background-color. | ||
Shorthand notation for setting the background. Equivalent to specifying background-color, background-image, background-repeat, and/orbackground-position. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QDialog, QFrame, QGroupBox,QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. Example: QTextEdit { background: yellow } Often, it is required to set a fill pattern similar to the styles in Qt::BrushStyle. You can use the background-color property for Qt::SolidPattern,Qt::RadialGradientPattern, Qt::LinearGradientPattern and Qt::ConicalGradientPattern. The other patterns are easily achieved by creating a background image that contains the pattern. Example: QLabel { background-image: url(dense6pattern.png); background-repeat: repeat-xy; } See also background-origin, selection-background-color, background-clip, background-attachment and alternate-background-color. | ||
The background color used for the widget. Examples: QLabel { background-color: yellow } QLineEdit { background-color: rgb(255, 0, 0) } | ||
The background image used for the widget. Semi-transparent parts of the image let the background-color shine through. Example: QFrame { background-image: url(:/images/hydro.png) } | ||
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: QFrame { background: white url(:/images/ring.png); background-repeat: repeat-y; background-position: left; } | ||
background-position | The alignment of the background image within the background-origin rectangle. If this property is not specified, the alignment is top left. Example: QFrame { background: url(:/images/footer.png); background-position: bottom left; } | |
Determines whether the background-image in a QAbstractScrollArea is scrolled or fixed with respect to the viewport. By default, the background-image scrolls with the viewport. Example: QTextEdit { background-image: url("leaves.png"); background-attachment: fixed; } See also background | ||
The widget's rectangle, in which the background is drawn. This property specifies the rectangle to which the background-color and background-image are clipped. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QDialog, QFrame, QGroupBox,QLabel, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. If this property is not specified, the default is border. Example: QFrame { background-image: url(:/images/header.png); background-position: top left; background-origin: content; background-clip: padding; } See also background, background-origin and The Box Model. | ||
The widget's background rectangle, to use in conjunction with background-position and background-image. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QDialog, QFrame, QGroupBox,QLabel, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. If this property is not specified, the default is padding. Example: QFrame { background-image: url(:/images/header.png); background-position: top left; background-origin: content; } See also background and The Box Model. | ||
Shorthand notation for setting the widget's border. Equivalent to specifying border-color, border-style, and/or border-width. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. Example: QLineEdit { border: 1px solid white } | ||
border-top | Shorthand notation for setting the widget's top border. Equivalent to specifying border-top-color, border-top-style, and/or border-top-width. | |
border-right | Shorthand notation for setting the widget's right border. Equivalent to specifying border-right-color, border-right-style, and/or border-right-width. | |
border-bottom | Shorthand notation for setting the widget's bottom border. Equivalent to specifying border-bottom-color, border-bottom-style, and/or border-bottom-width. | |
border-left | Shorthand notation for setting the widget's left border. Equivalent to specifying border-left-color, border-left-style, and/or border-left-width. | |
The color of all the border's edges. Equivalent to specifying border-top-color, border-right-color, border-bottom-color, and border-left-color. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. If this property is not specified, it defaults to color (i.e., the widget's foreground color). Example: QLineEdit { border-width: 1px; border-style: solid; border-color: white; } See also border-style, border-width, border-image, and The Box Model. | ||
border-top-color | The color of the border's top edge. | |
border-right-color | The color of the border's right edge. | |
border-bottom-color | The color of the border's bottom edge. | |
border-left-color | The color of the border's left edge. | |
The image used to fill the border. The image is cut into nine parts and stretched appropriately if necessary. See Border Image for details. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit and QToolTip. See also border-color, border-style, border-width, and The Box Model. | ||
The radius of the border's corners. Equivalent to specifying border-top-left-radius, border-top-right-radius, border-bottom-right-radius, and border-bottom-left-radius. The border-radius clips the element's background. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to 0. Example: QLineEdit { border-width: 1px; border-style: solid; border-radius: 4px; } See also border-width and The Box Model. | ||
border-top-left-radius | The radius of the border's top-left corner. | |
border-top-right-radius | The radius of the border's top-right corner. | |
border-bottom-right-radius | The radius of the border's bottom-right corner. Setting this property to a positive value results in a rounded corner. | |
border-bottom-left-radius | The radius of the border's bottom-left corner. Setting this property to a positive value results in a rounded corner. | |
The style of all the border's edges. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to none. Example: QLineEdit { border-width: 1px; border-style: solid; border-color: blue; } See also border-color, border-style, border-image, and The Box Model. | ||
border-top-style | The style of the border's top edge. | |
border-right-style | The style of the border's right edge/ | |
border-bottom-style | The style of the border's bottom edge. | |
border-left-style | The style of the border's left edge. | |
The width of the border. Equivalent to setting border-top-width, border-right-width, border-bottom-width, and border-left-width. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. Example: QLineEdit { border-width: 2px; border-style: solid; border-color: darkblue; } See also border-color, border-radius, border-style, border-image, and The Box Model. | ||
border-top-width | The width of the border's top edge. | |
border-right-width | The width of the border's right edge. | |
border-bottom-width | The width of the border's bottom edge. | |
border-left-width | The width of the border's left edge. | |
If position is relative (the default), moves a subcontrol by a certain offset up; specifying bottom: y is then equivalent to specifying top: -y. If position is absolute, the bottom property specifies the subcontrol's bottom edge in relation to the parent's bottom edge (see also subcontrol-origin). Example: QSpinBox::down-button { bottom: 2px } | ||
The layout of buttons in a QDialogButtonBox or a QMessageBox. The possible values are 0 (WinLayout), 1 (MacLayout), 2 (KdeLayout), and 3 (GnomeLayout). If this property is not specified, it defaults to the value specified by the current style for the SH_DialogButtonLayout style hint. Example: * { button-layout: 2 } | ||
The color used to render text. This property is supported by all widgets that respect the QWidget::palette. If this property is not set, the default is whatever is set for in the widget's palette for the QWidget::foregroundRole (typically black). Example: QPushButton { color: red } See also background and selection-color. | ||
dialogbuttonbox-buttons-have-icons | Whether the buttons in a QDialogButtonBox show icons If this property is set to 1, the buttons of a QDialogButtonBox show icons; if it is set to 0, the icons are not shown. See the List of Icons section for information on how to set icons. QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 1; } Note: Styles defining this property must be applied before the QDialogButtonBox is created; this means that you must apply the style to the parent widget or to the application itself. | |
Shorthand notation for setting the text's font. Equivalent to specifying font-family, font-size, font-style, and/or font-weight. This property is supported by all widgets that respect the QWidget::font. If this property is not set, the default is the QWidget::font. Example: QCheckBox { font: bold italic large "Times New Roman" } | ||
font-family | String | The font family. Example: QCheckBox { font-family: "New Century Schoolbook" } |
font-size | The font size. In this version of Qt, only pt and px metrics are supported. Example: QTextEdit { font-size: 12px } | |
font-style | The font style. Example: QTextEdit { font-style: italic } | |
font-weight | The weight of the font. | |
The color of the grid line in a QTableView. If this property is not specified, it defaults to the value specified by the current style for the SH_Table_GridLineColor style hint. Example: * { gridline-color: gray } | ||
The height of a subcontrol (or in some case, a widget). If this property is not specified, it defaults to a value that depends on the subcontrol/widget and on the current style. Warning: Unless otherwise specified, this property has no effect when set on widgets. If you want a widget with a fixed height, set the min-height and max-height to the same value. Example: QSpinBox::down-button { height: 10px } See also width. | ||
The width and height of the icon in a widget. The icon size of the following widgets can be set using this property. § QTabBar § QToolBar § QToolBox | ||
Url+ | 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. Warning: The QIcon SVG plugin is needed to render SVG images. Example: /* implicitly sets the size of down-button to the size of spindown.png */ QSpinBox::down-button { image: url(:/images/spindown.png) } | |
In Qt 4.3 and later, the alignment of the image image's position can be specified using relative or absolute position. | ||
If position is relative (the default), moves a subcontrol by a certain offset to the right. If position is absolute, the left property specifies the subcontrol's left edge in relation to the parent's left edge (see also subcontrol-origin). If this property is not specified, it defaults to 0. Example: QSpinBox::down-button { left: 2px } | ||
The QLineEdit password character as a Unicode number. If this property is not specified, it defaults to the value specified by the current style for the SH_LineEdit_PasswordCharacter style hint. Example: * { lineedit-password-character: 9679 } | ||
The widget's margins. Equivalent to specifying margin-top, margin-right, margin-bottom, and margin-left. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to 0. Example: QLineEdit { margin: 2px } See also padding, spacing, and The Box Model. | ||
margin-top | The widget's top margin. | |
margin-right | The widget's right margin. | |
margin-bottom | The widget's bottom margin. | |
margin-left | The widget's left margin. | |
The widget's or a subcontrol's maximum height. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. The value is relative to the contents rect in the box model. Example: QSpinBox { max-height: 24px } See also max-width. | ||
The widget's or a subcontrol's maximum width. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. The value is relative to the contents rect in the box model. Example: QComboBox { max-width: 72px } See also max-height. | ||
The interaction behavior for text in a message box. Possible values are based on Qt::TextInteractionFlags. If this property is not specified, it defaults to the value specified by the current style for the SH_MessageBox_TextInteractionFlags style hint. Example: QMessageBox { messagebox-text-interaction-flags: 5 } | ||
The widget's or a subcontrol's minimum height. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. If this property is not specified, the minimum height is derived based on the widget's contents and the style. The value is relative to the contents rect in the box model. Example: QComboBox { min-height: 24px } See also min-width. | ||
The widget's or a subcontrol's minimum width. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox, QSplitter, QStatusBar, QTextEdit, and QToolTip. If this property is not specified, the minimum width is derived based on the widget's contents and the style. The value is relative to the contents rect in the box model. Example: QComboBox { min-width: 72px } See also min-height. | ||
The opacity for a widget. Possible values are from 0 (transparent) to 255 (opaque). For the moment, this is only supported for tooltips. If this property is not specified, it defaults to the value specified by the current style for the SH_ToolTipLabel_Opacity style hint. Example: QToolTip { opacity: 223 } | ||
The widget's padding. Equivalent to specifying padding-top, padding-right, padding-bottom, and padding-left. This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel,QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to 0. Example: QLineEdit { padding: 3px } See also margin, spacing, and The Box Model. | ||
padding-top | The widget's top padding. | |
padding-right | The widget's right padding. | |
padding-bottom | The widget's bottom padding. | |
padding-left | The widget's left padding. | |
bool | Whether the QTreeView paints alternating row colors for the empty area (i.e the area where there are no items) | |
relative | Whether offsets specified using left, right, top, and bottom are relative or absolute coordinates. If this property is not specified, it defaults to relative. | |
If position is relative (the default), moves a subcontrol by a certain offset to the left; specifying right: x is then equivalent to specifying left: -x. If position is absolute, the right property specifies the subcontrol's right edge in relation to the parent's right edge (see also subcontrol-origin). Example: QSpinBox::down-button { right: 2px } | ||
The background of selected text or items. This property is supported by all widgets that respect the QWidget::palette and that show selection text. If this property is not set, the default value is whatever is set for the palette's Highlight role. Example: QTextEdit { selection-background-color: darkblue } See also selection-color and background. | ||
The foreground of selected text or items. This property is supported by all widgets that respect the QWidget::palette and that show selection text. If this property is not set, the default value is whatever is set for the palette's HighlightedText role. Example: QTextEdit { selection-color: white } See also selection-background-color and color. | ||
Controls whether selections in a QListView cover the entire row or just the extent of the text. If this property is not specified, it defaults to the value specified by the current style for the SH_ItemView_ShowDecorationSelected style hint. Example: * { show-decoration-selected: 1 } | ||
Internal spacing in the widget. This property is supported by QCheckBox, checkable QGroupBoxes, QMenuBar, and QRadioButton. If this property is not specified, the default value depends on the widget and on the current style. Example: QMenuBar { spacing: 10 } | ||
The origin rectangle of the subcontrol within the parent element. If this property is not specified, the default is padding. Example: QSpinBox::up-button { image: url(:/images/spinup.png); subcontrol-origin: content; subcontrol-position: right top; } See also subcontrol-position. | ||
The alignment of the subcontrol within the origin rectangle specified by subcontrol-origin. If this property is not specified, it defaults to a value that depends on the subcontrol. Example: QSpinBox::down-button { image: url(:/images/spindown.png); subcontrol-origin: padding; subcontrol-position: right bottom; } See also subcontrol-origin. | ||
The alignment of text and icon within the contents of the widget. If this value is not specified, it defaults to the value that depends on the native style. Example: QPushButton { text-align: left; } This property is currently supported only by QPushButton and QProgressBar. | ||
text-decoration | none | Additional text effects |
If position is relative (the default), moves a subcontrol by a certain offset down. If position is absolute, the top property specifies the subcontrol's top edge in relation to the parent's top edge (see also subcontrol-origin). If this property is not specified, it defaults to 0. Example: QSpinBox::up-button { top: 2px } | ||
The width of a subcontrol (or a widget in some cases). If this property is not specified, it defaults to a value that depends on the subcontrol/widget and on the current style. Warning: Unless otherwise specified, this property has no effect when set on widgets. If you want a widget with a fixed width, set the min-width and max-width to the same value. Example: QSpinBox::up-button { width: 12px } See also height. |