【QT】3 - [QStyle] Qt通用属性列表

通用属性列表  -  List of Properties

下列表格中的Qt样式表支持所有的Qt控件,除非有特殊声明的,在列表中含有*号的表示和 CSS2 or CSS3有很大区别的属性。

Property

Type

Description

alternate-background-color

Brush 

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.

background

Background

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, QCheckBoxQComboBoxQDialogQFrameQGroupBox,QLabelQLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEditQToolTip, 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::RadialGradientPatternQt::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-originselection-background-colorbackground-clipbackground-attachment and alternate-background-color.

background-color

Brush 

The background color used for the widget.

Examples:

 QLabel { background-color: yellow }

 QLineEdit { background-color: rgb(255, 0, 0) }

background-image

Url

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) }

background-repeat

Repeat

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

Alignment

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;

 }

background-attachment

Attachment

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

background-clip

Origin

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, QCheckBoxQComboBoxQDialogQFrameQGroupBox,QLabelQPushButtonQRadioButtonQSplitterQTextEditQToolTip, 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 backgroundbackground-origin and The Box Model.

background-origin

Origin

The widget's background rectangle, to use in conjunction with background-position and background-image.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQDialogQFrameQGroupBox,QLabelQPushButtonQRadioButtonQSplitterQTextEditQToolTip, 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.

border

Border

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEditQToolTip, and plain QWidgets.

Example:

 QLineEdit { border: 1px solid white }

border-top

Border

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

Border

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

Border

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

Border

Shorthand notation for setting the widget's left border. Equivalent to specifying border-left-color, border-left-style, and/or border-left-width.

border-color 

Box Colors

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEditQToolTip, 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-styleborder-widthborder-image, and The Box Model.

border-top-color

Brush 

The color of the border's top edge.

border-right-color

Brush 

The color of the border's right edge.

border-bottom-color

Brush 

The color of the border's bottom edge.

border-left-color

Brush 

The color of the border's left edge.

border-image

Border Image

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit and QToolTip.

See also border-colorborder-styleborder-width, and The Box Model.

border-radius

Radius

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit, 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

Radius

The radius of the border's top-left corner.

border-top-right-radius

Radius

The radius of the border's top-right corner.

border-bottom-right-radius

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

Radius

The radius of the border's bottom-left corner. Setting this property to a positive value results in a rounded corner.

border-style

Border Style

The style of all the border's edges.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit, 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-colorborder-styleborder-image, and The Box Model.

border-top-style

Border Style

The style of the border's top edge.

border-right-style

Border Style

The style of the border's right edge/

border-bottom-style

Border Style

The style of the border's bottom edge.

border-left-style

Border Style

The style of the border's left edge.

border-width

Box Lengths

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit, and QToolTip.

Example:

 QLineEdit {

     border-width: 2px;

     border-style: solid;

     border-color: darkblue;

 }

See also border-colorborder-radiusborder-styleborder-image, and The Box Model.

border-top-width

Length

The width of the border's top edge.

border-right-width

Length

The width of the border's right edge.

border-bottom-width

Length

The width of the border's bottom edge.

border-left-width

Length

The width of the border's left edge.

bottom

Length

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 }

See also leftright, and top.

button-layout

Number

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 }

color

Brush 

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

Boolean

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.

font

Font

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

Font Size

The font size. In this version of Qt, only pt and px metrics are supported.

Example:

 QTextEdit { font-size: 12px }

font-style

Font Style

The font style.

Example:

 QTextEdit { font-style: italic }

font-weight

Font Weight

The weight of the font.

gridline-color*

Color 

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 }

height

Length

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.

icon-size

Length

The width and height of the icon in a widget.

The icon size of the following widgets can be set using this property.

§ QCheckBox

§ QListView

§ QPushButton

§ QRadioButton

§ QTabBar

§ QToolBar

§ QToolBox

QTreeView

image*

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) }

image-position

alignment

In Qt 4.3 and later, the alignment of the image image's position can be specified using relative or absolute position.

left

Length

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 }

See also righttop, and bottom.

lineedit-password-character*

Number

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 }

margin

Box Lengths

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit, and QToolTip.

If this property is not specified, it defaults to 0.

Example:

 QLineEdit { margin: 2px }

See also paddingspacing, and The Box Model.

margin-top

Length

The widget's top margin.

margin-right

Length

The widget's right margin.

margin-bottom

Length

The widget's bottom margin.

margin-left

Length

The widget's left margin.

max-height

Length

The widget's or a subcontrol's maximum height.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSizeGripQSpinBoxQSplitterQStatusBarQTextEdit, and QToolTip.

The value is relative to the contents rect in the box model.

Example:

 QSpinBox { max-height: 24px }

See also max-width.

max-width

Length

The widget's or a subcontrol's maximum width.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSizeGripQSpinBoxQSplitterQStatusBarQTextEdit, and QToolTip.

The value is relative to the contents rect in the box model.

Example:

 QComboBox { max-width: 72px }

See also max-height.

messagebox-text-interaction-flags*

Number

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 }

min-height

Length

The widget's or a subcontrol's minimum height.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSizeGripQSpinBoxQSplitterQStatusBarQTextEdit, 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.

min-width

Length

The widget's or a subcontrol's minimum width.

This property is supported by QAbstractItemView subclasses, QAbstractSpinBox subclasses, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSizeGripQSpinBoxQSplitterQStatusBarQTextEdit, 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.

opacity*

Number

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 }

padding

Box Lengths

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, QCheckBoxQComboBoxQFrameQGroupBoxQLabel,QLineEditQMenuQMenuBarQPushButtonQRadioButtonQSplitterQTextEdit, and QToolTip.

If this property is not specified, it defaults to 0.

Example:

 QLineEdit { padding: 3px }

See also marginspacing, and The Box Model.

padding-top

Length

The widget's top padding.

padding-right

Length

The widget's right padding.

padding-bottom

Length

The widget's bottom padding.

padding-left

Length

The widget's left padding.

paint-alternating-row-colors-for-empty-area

bool

Whether the QTreeView paints alternating row colors for the empty area (i.e the area where there are no items)

position

relative 
| absolute

Whether offsets specified using leftrighttop, and bottom are relative or absolute coordinates.

If this property is not specified, it defaults to relative.

right

Length

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 }

See also lefttop, and bottom.

selection-background-color*

Brush 

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.

selection-color*

Brush 

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.

show-decoration-selected*

Boolean

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 }

spacing*

Length

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 }

See also padding and margin.

subcontrol-origin*

Origin

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.

subcontrol-position*

Alignment

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.

text-align

Alignment

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 
underline 
overline 
line-through

Additional text effects

top

Length

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 }

See also leftright, and bottom.

width

Length

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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值