Qt样式表支持各种属性、伪状态和子控件,使得定制小部件的外观成为可能。
下表列出了可以使用样式表自定义的Qt小部件:
Widget | 如何设计风格 |
---|---|
QAbstractScrollArea | Supports the box model. All derivatives of QAbstractScrollArea, including QTextEdit, and QAbstractItemView (all item view classes), support scrollable backgrounds using background-attachment. Setting the background-attachment to a background-image that does not scroll with the viewport. Setting the background-attachment to See Customizing QAbstractScrollArea for an example. 支持盒子模型。 QAbstractScrollArea 的所有派生类,包括 QTextEdit 和 QAbstractItemView(所有项目视图类),都支持使用background-attachment的可滚动背景。 将 background-attachment 设置为 fixed 会提供不随视口滚动的background-image。 设置background-attachment滚动【
|
QCheckBox | Supports the box model. The check indicator can be styled using the ::indicator subcontrol. By default, the indicator is placed in the Top Left corner of the Contents rectangle of the widget. The spacing property specifies the spacing between the check indicator and the text. See Customizing QCheckBox for an example. 支持盒子模型。 可以使用 ::indicator 子控件设置检查指示器的样式。 默认情况下,指示器放置在小部件内容矩形的左上角。 间距属性指定检查指示符和文本之间的间距。 有关示例,请参阅自定义 QCheckBox。 |
QColumnView | The grip can be styled be using the image property. The arrow indicators can by styled using the ::left-arrow subcontrol and the ::right-arrow subcontrol. 可以使用图像属性来设置手柄的样式。 箭头指示符可以使用 ::left-arrow 子控件和 ::right-arrow 子控件来设置样式。 |
QComboBox | The frame around the combobox can be styled using the box model. The drop-down button can be styled using the ::drop-down subcontrol. By default, the drop-down button is placed in the top right corner of the padding rectangle of the widget. The arrow mark inside the drop-down button can be styled using the ::down-arrow subcontrol. By default, the arrow is placed in the center of the contents rectangle of the drop-down subcontrol. See Customizing QComboBox for an example. 组合框周围的框架可以使用框模型进行样式设置。 下拉按钮可以使用 ::drop-down 子控件设置样式。 默认情况下,下拉按钮位于小部件填充矩形的右上角。 下拉按钮内的箭头标记可以使用 ::down-arrow 子控件设置样式。 默认情况下,箭头位于下拉子控件的内容矩形的中心。 有关示例,请参阅自定义 QComboBox。 |
QDateEdit | See QSpinBox. |
QDateTimeEdit | See QSpinBox. |
QDialog | Supports only the background, background-clip and background-origin properties. Warning: Make sure you define the Q_OBJECT macro for your custom widget. 仅支持背景、背景剪辑和背景原点属性。 警告:确保为自定义小部件定义 Q_OBJECT 宏。 |
QDialogButtonBox | The layout of buttons can be altered using the button-layout property. 可以使用 button-layout 属性更改按钮的布局。 |
QDockWidget | Supports styling of the title bar and the title bar buttons when docked. The dock widget border can be styled using the border property. The ::title subcontrol can be used to customize the title bar. The close and float buttons are positioned with respect to the ::title subcontrol using the ::close-button and ::float-button respectively. When the title bar is vertical, the :vertical pseudo class is set. In addition, depending on QDockWidget::DockWidgetFeature, the :closable, :floatable and :movable pseudo states are set. Note: Use QMainWindow::separator to style the resize handle. Warning: The style sheet has no effect when the QDockWidget is undocked as Qt uses native top level windows when undocked. See Customizing QDockWidget for an example.
停靠时支持标题栏和标题栏按钮的样式。 可以使用 border 属性设置停靠窗口小部件边框的样式。 ::title 子控件可用于自定义标题栏。 关闭和浮动按钮分别使用 ::close-button 和 ::float-button 相对于 ::title 子控件定位。 当标题栏是垂直的时,设置了 :vertical 伪类。 此外,根据 QDockWidget::DockWidgetFeature,设置 :closeable、:floatable 和 :movable 伪状态。 注意:使用 QMainWindow::separator 设置调整大小手柄的样式。 警告:当 QDockWidget 取消停靠时,样式表不起作用,因为 Qt 在取消停靠时使用本机顶级窗口。 有关示例,请参阅自定义 QDockWidget。 |
QDoubleSpinBox | See QSpinBox. |
QFrame | Supports the box model. Since 4.3, setting a stylesheet on a QLabel automatically sets the QFrame::frameStyle property to QFrame::StyledPanel. See Customizing QFrame for an example. 支持盒子模型。 从 4.3 开始,在 QLabel 上设置样式表会自动将 QFrame::frameStyle 属性设置为 QFrame::StyledPanel。 有关示例,请参阅自定义 QFrame。 |
QGroupBox | Supports the box model. The title can be styled using the ::title subcontrol. By default, the title is placed depending on QGroupBox::textAlignment. In the case of a checkable QGroupBox, the title includes the check indicator. The indicator is styled using the ::indicator subcontrol. The spacing property can be used to control the spacing between the text and indicator. See Customizing QGroupBox for an example. 支持盒子模型。 可以使用 ::title 子控件设置标题的样式。 默认情况下,标题根据 QGroupBox::textAlignment 放置。 对于可检查的 QGroupBox,标题包含检查指示符。 指示器的样式使用 ::indicator 子控件。 间距属性可用于控制文本和指示器之间的间距。 有关示例,请参阅自定义 QGroupBox。 |
QHeaderView | Supports the box model. The sections of the header view are styled using the ::section sub control. The section Sub-control supports the :middle, :first, :last, :only-one, :next-selected, :previous-selected, :selected, and :checked pseudo states. The sort indicator can be styled using the ::up-arrow and the ::down-arrow Sub-control. See Customizing QHeaderView for an example. 支持盒子模型。 标题视图的部分使用 ::section 子控件设置样式。 子控件部分支持:middle、:first、:last、:only-one、:next-selected、:previous-selected、:selected 和 :checked 伪状态。 可以使用 ::up-arrow 和 ::down-arrow 子控件来设置排序指示器的样式。 有关示例,请参阅自定义 QHeaderView。 |
QLabel | Supports the box model. Does not support the :hover pseudo-state. Since 4.3, setting a stylesheet on a QLabel automatically sets the QFrame::frameStyle property to QFrame::StyledPanel. See Customizing QFrame for an example (a QLabel derives from QFrame). 支持盒子模型。 不支持 :hover 伪状态。 从 4.3 开始,在 QLabel 上设置样式表会自动将 QFrame::frameStyle 属性设置为 QFrame::StyledPanel。 有关示例,请参阅自定义 QFrame(QLabel 派生自 QFrame)。 |
QLineEdit | Support the box model. The color and background of the selected item is styled using selection-color and selection-background-color respectively. The password character can be styled using the lineedit-password-character property. The password mask delay can be changed using the lineedit-password-mask-delay See Customizing QLineEdit for an example. 支持盒子模型。 所选项目的颜色和背景分别使用 selection-color 和 selection-background-color 设置样式。 可以使用 lineedit-password-character 属性设置密码字符的样式。 可以使用 lineedit-password-mask-delay 更改密码掩码延迟 有关示例,请参阅自定义 QLineEdit。 |
QListView | Supports the box model. When alternating row colors is enabled, the alternating colors can be styled using the alternate-background-color property. The color and background of the selected item is styled using selection-color and selection-background-color respectively. The selection behavior is controlled by the show-decoration-selected property. Use the ::item subcontrol for more fine grained control over the items in the QListView. See QAbsractScrollArea to style scrollable backgrounds. See Customzing QListView for an example. 支持盒子模型。 启用交替行颜色后,可以使用交替背景颜色属性设置交替颜色的样式。 所选项目的颜色和背景分别使用 selection-color 和 selection-background-color 设置样式。 选择行为由 show-decoration-selected 属性控制。 使用 ::item 子控件对 QListView 中的项目进行更细粒度的控制。 请参阅 QAbsractScrollArea 以设置可滚动背景的样式。 有关示例,请参阅自定义 QListView。 |
QListWidget | See QListView. |
QMainWindow | Supports styling of the separator The separator in a QMainWindow when using QDockWidget is styled using the ::separator subcontrol. See Customizing QMainWindow for an example. 支持分隔符的样式 使用 QDockWidget 时 QMainWindow 中的分隔符使用 ::separator 子控件进行样式设置。 有关示例,请参阅自定义 QMainWindow。 |
QMenu | Supports the box model. Individual items are styled using the ::item subcontrol. In addition to the usually supported pseudo states, The indicator of checkable menu items is styled using the ::indicator subcontrol. The separator is styled using the ::separator subcontrol. For items with a sub menu, the arrow marks are styled using the right-arrow and left-arrow. The scroller is styled using the ::scroller. The tear-off is styled using the ::tearoff. See Customizing QMenu for an example. 支持盒子模型。 单个项目使用 ::item 子控件设置样式。 除了通常支持的伪状态外,项目子控件还支持 :selected、:default、:exclusive 和 non-exclusive 伪状态。 可检查菜单项的指示器使用 ::indicator 子控件设置样式。 分隔符使用 ::separator 子控件设置样式。 对于带有子菜单的项目,箭头标记的样式使用向右箭头和向左箭头。 滚动条使用 ::scroller 设置样式。 撕下的样式使用 ::tearoff。 有关示例,请参阅自定义 QMenu。 |
QMenuBar | Supports the box model. The spacing property specifies the spacing between menu items. Individual items are styled using the ::item subcontrol. Warning: When running on Qt/Mac, the menu bar is usually embedded into the system-wide menu bar. In this case, the style sheet will have no effect. See Customizing QMenuBar for an example. 支持盒子模型。 间距属性指定菜单项之间的间距。 单个项目使用 ::item 子控件设置样式。 警告:在 Qt/Mac 上运行时,菜单栏通常嵌入到系统范围的菜单栏中。 在这种情况下,样式表将不起作用。 有关示例,请参阅自定义 QMenuBar。 |
QMessageBox | The messagebox-text-interaction-flags property can be used to alter the interaction with text in the message box. messagebox-text-interaction-flags 属性可用于更改与消息框中文本的交互。 |
QProgressBar | Supports the box model. The chunks of the progress bar can be styled using the ::chunk subcontrol. The chunk is displayed on the Contents rectangle of the widget. If the progress bar displays text, use the text-align property to position the text. Indeterminate progress bars have the :indeterminate pseudo state set. See Customizing QProgressBar for an example. 支持盒子模型。 进度条的块可以使用 ::chunk 子控件设置样式。 该块显示在小部件的内容矩形上。 如果进度条显示文本,请使用 text-align 属性来定位文本。 不确定进度条设置了 :indeterminate 伪状态。 有关示例,请参阅自定义 QProgressBar。 |
QPushButton | Supports the box model. Supports the :default, :flat, :checked pseudo states. Since 5.15, the icon property can be set to override the button icon. For QPushButton with a menu, the menu indicator is styled using the ::menu-indicator subcontrol. Appearance of checkable push buttons can be customized using the :open and :closed pseudo-states. Warning: If you only set a background-color on a QPushButton, the background may not appear unless you set the border property to some value. This is because, by default, the QPushButton draws a native border which completely overlaps the background-color. For example, See Customizing QPushButton for an example. 支持盒子模型。 支持:default、:flat、:checked 伪状态。 从 5.15 开始,图标属性可以设置为覆盖按钮图标。 对于带有菜单的 QPushButton,菜单指示器的样式使用 ::menu-indicator 子控件。 可以使用 :open 和 :closed 伪状态自定义可检查按钮的外观。 警告:如果您只在 QPushButton 上设置背景颜色,除非您将边框属性设置为某个值,否则背景可能不会出现。 这是因为默认情况下,QPushButton 会绘制一个与背景颜色完全重叠的原生边框。 例如, QPushButton { background-color: red; border: none; }有关示例,请参阅自定义 QPushButton。 |
QRadioButton | Supports the box model. The check indicator can be styled using the ::indicator subcontrol. By default, the indicator is placed in the Top Left corner of the Contents rectangle of the widget. The spacing property specifies the spacing between the check indicator and the text. See Customizing QRadioButton for an example. 支持盒子模型。 可以使用 ::indicator 子控件设置检查指示器的样式。 默认情况下,指示器放置在小部件内容矩形的左上角。 间距属性指定检查指示符和文本之间的间距。 有关示例,请参阅自定义 QRadioButton。 |
QScrollBar | Supports the box model. The Contents rectangle of the widget is considered to be the groove over which the slider moves. The extent of the QScrollBar (i.e the width or the height depending on the orientation) is set using the width or height property respectively. To determine the orientation, use the :horizontal and the :vertical pseudo states. The slider can be styled using the ::handle subcontrol. Setting the min-width or min-height provides size contraints for the slider depending on the orientation. The ::add-line subcontrol can be used to style the button to add a line. By default, the add-line subcontrol is placed in top right corner of the Border rectangle of the widget. Depending on the orientation the ::right-arrow or ::down-arrow. By default, the arrows are placed in the center of the Contents rectangle of the add-line subcontrol. The ::sub-line subcontrol can be used to style the button to subtract a line. By default, the sub-line subcontrol is placed in bottom right corner of the Border rectangle of the widget. Depending on the orientation the ::left-arrow or ::up-arrow. By default, the arrows are placed in the center of the Contents rectangle of the sub-line subcontrol. The ::sub-page subcontrol can be used to style the region of the slider that subtracts a page. The ::add-page subcontrol can be used to style the region of the slider that adds a page. See Customizing QScrollBar for an example. 支持盒子模型。小部件的内容矩形被认为是滑块移动的凹槽。 QScrollBar 的范围(即宽度或高度取决于方向)分别使用 width 或 height 属性设置。要确定方向,请使用 :horizontal 和 :vertical 伪状态。 滑块可以使用 ::handle 子控件设置样式。设置 min-width 或 min-height 会根据方向为滑块提供尺寸限制。 ::add-line 子控件可用于设置按钮样式以添加一行。默认情况下,添加行子控件位于小部件边框矩形的右上角。根据方向,::right-arrow 或 ::down-arrow。默认情况下,箭头位于添加行子控件的内容矩形的中心。 ::sub-line 子控件可用于设置按钮样式以减去一行。默认情况下,子行子控件放置在小部件的边框矩形的右下角。根据方向,::left-arrow 或 ::up-arrow。默认情况下,箭头放置在子行子控件的内容矩形的中心。 ::sub-page 子控件可用于设置减去页面的滑块区域的样式。 ::add-page 子控件可用于设置添加页面的滑块区域的样式。 有关示例,请参阅自定义 QScrollBar。 |
QSizeGrip | Supports the width, height, and image properties. See Customizing QSizeGrip for an example. 支持宽度、高度和图像属性。 有关示例,请参阅自定义 QSizeGrip。 |
QSlider | Supports the box model. For horizontal slides, the min-width and height properties must be provided. For vertical sliders, the min-height and width properties must be provided. The groove of the slider is styled using the ::groove. The groove is positioned by default in the Contents rectangle of the widget. The thumb of the slider is styled using ::handle subcontrol. The subcontrol moves in the Contents rectangle of the groove subcontrol. See Customizing QSlider for an example. 支持盒子模型。 对于水平幻灯片,必须提供 min-width 和 height 属性。 对于垂直滑块,必须提供 min-height 和 width 属性。 滑块的凹槽使用 ::groove 设计。 默认情况下,凹槽位于小部件的内容矩形中。 滑块的拇指使用 ::handle 子控件设置样式。 子控件在凹槽子控件的内容矩形中移动。 有关示例,请参阅自定义 QSlider。 |
QSpinBox | The frame of the spin box can be styled using the box model. The up button and arrow can be styled using the ::up-button and ::up-arrow subcontrols. By default, the up-button is placed in the top right corner in the Padding rectangle of the widget. Without an explicit size, it occupies half the height of its reference rectangle. The up-arrow is placed in the center of the Contents rectangle of the up-button. The down button and arrow can be styled using the ::down-button and ::down-arrow subcontrols. By default, the down-button is placed in the bottom right corner in the Padding rectangle of the widget. Without an explicit size, it occupies half the height of its reference rectangle. The bottom-arrow is placed in the center of the Contents rectangle of the bottom-button. See Customizing QSpinBox for an example. 旋转框的框架可以使用框模型进行样式设置。 可以使用 ::up-button 和 ::up-arrow 子控件设置向上按钮和箭头的样式。 默认情况下,向上按钮位于小部件的 Padding 矩形的右上角。 没有明确的大小,它占据其参考矩形高度的一半。 向上箭头位于向上按钮的内容矩形的中心。 可以使用 ::down-button 和 ::down-arrow 子控件设置向下按钮和箭头的样式。 默认情况下,向下按钮位于小部件的 Padding 矩形的右下角。 没有明确的大小,它占据其参考矩形高度的一半。 底部箭头位于底部按钮的内容矩形的中心。 有关示例,请参阅自定义 QSpinBox。 |
QSplitter | Supports the box model. The handle of the splitter is styled using the ::handle subcontrol. See Customizing QSplitter for an example. 支持盒子模型。 拆分器的句柄使用 ::handle 子控件进行样式设置。 有关示例,请参阅自定义 QSplitter。 |
QStatusBar | Supports only the background property. The frame for individual items can be style using the ::item subcontrol. See Customizing QStatusBar for an example. 仅支持背景属性。 单个项目的框架可以使用 ::item 子控件进行样式设置。 有关示例,请参阅自定义 QStatusBar。 |
QTabBar | Individual tabs may be styled using the ::tab subcontrol. Close buttons using the ::close-button The tabs support the :only-one, :first, :last, :middle, :previous--selected, :next-selected, :selected pseudo states. The :top, :left, :right, :bottom pseudo states depending on the orientation of the tabs. Overlapping tabs for the selected state are created by using negative margins or using the The tear indicator of the QTabBar is styled using the ::tear subcontrol. QTabBar used two QToolButtons for its scrollers that can be styled using the The alignment of the tabs within the QTabBar is styled using the alignment property. Warning: To change the position of the QTabBar within a QTabWidget, use the tab-bar subcontrol (and set subcontrol-position). See Customizing QTabBar for an example. 可以使用 ::tab 子控件设置单个选项卡的样式。 使用 ::close-button 的关闭按钮选项卡支持 :only-one, :first, :last, :middle, :previous--selected, :next-selected, :selected 伪状态。 :top, :left, :right, :bottom 伪状态取决于选项卡的方向。 所选状态的重叠标签是通过使用负边距或使用绝对位置方案创建的。 QTabBar 的撕裂指示器使用 ::tear 子控件设置样式。 QTabBar 为其滚动条使用了两个 QToolButton,可以使用 QTabBar QToolButton 选择器设置样式。 要指定滚动按钮的宽度,请使用 ::scroller 子控件。 QTabBar 中选项卡的对齐方式使用 alignment 属性设置样式。 警告: 要更改 QTabBar 在 QTabWidget 中的位置,请使用标签栏子控件(并设置子控件位置)。 有关示例,请参阅自定义 QTabBar。 |
QTabWidget | The frame of the tab widget is styled using the ::pane subcontrol. The left and right corners are styled using the ::left-corner and ::right-corner respectively. The position of the tab bar is controlled using the ::tab-bar subcontrol. By default, the subcontrols have positions of a QTabWidget in the QWindowsStyle. To place the QTabBar in the center, set the subcontrol-position of the tab-bar subcontrol. The :top, :left, :right, :bottom pseudo states depending on the orientation of the tabs. See Customizing QTabWidget for an example. 标签小部件的框架使用 ::pane 子控件进行样式设置。 左右角分别使用 ::left-corner 和 ::right-corner 进行样式设置。 标签栏的位置是使用 ::tab-bar 子控件控制的。 默认情况下,子控件在 QWindowsStyle 中具有 QTabWidget 的位置。 要将 QTabBar 置于中心,请设置标签栏子控件的子控件位置。 :top, :left, :right, :bottom 伪状态取决于选项卡的方向。 有关示例,请参阅自定义 QTabWidget。 |
QTableView | Supports the box model. When alternating row colors is enabled, the alternating colors can be styled using the alternate-background-color property. The color and background of the selected item is styled using selection-color and selection-background-color respectively. The corner widget in a QTableView is implemented as a QAbstractButton and can be styled using the "QTableView QTableCornerButton::section" selector. Warning: If you only set a background-color on a QTableCornerButton, the background may not appear unless you set the border property to some value. This is because, by default, the QTableCornerButton draws a native border which completely overlaps the background-color. The color of the grid can be specified using the gridline-color property. See QAbsractScrollArea to style scrollable backgrounds. See Customzing QTableView for an example. 支持盒子模型。 启用交替行颜色后,可以使用交替背景颜色属性设置交替颜色的样式。 所选项目的颜色和背景分别使用 selection-color 和 selection-background-color 设置样式。 QTableView 中的角小部件作为 QAbstractButton 实现,可以使用“QTableView QTableCornerButton::section”选择器设置样式。 警告:如果您只在 QTableCornerButton 上设置背景颜色,除非您将边框属性设置为某个值,否则背景可能不会出现。 这是因为,默认情况下, QTableCornerButton 绘制一个与背景颜色完全重叠的原生边框。 可以使用 gridline-color 属性指定网格的颜色。 请参阅 QAbsractScrollArea 以设置可滚动背景的样式。 有关示例,请参阅自定义 QTableView。 |
QTableWidget | See QTableView. |
QTextEdit | Supports the box model. The color and background of selected text is styled using selection-color and selection-background-color respectively. See QAbsractScrollArea to style scrollable backgrounds. 支持盒子模型。 所选文本的颜色和背景分别使用 selection-color 和 selection-background-color 设置样式。 请参阅 QAbsractScrollArea 以设置可滚动背景的样式。 |
QTimeEdit | See QSpinBox. |
QToolBar | Supports the box model. The :top, :left, :right, :bottom pseudo states depending on the area in which the tool bar is grouped. The :first, :last, :middle, :only-one pseudo states indicator the position of the tool bar within a line group (See QStyleOptionToolBar::positionWithinLine). The separator of a QToolBar is styled using the ::separator subcontrol. The handle (to move the toolbar) is styled using the ::handle subcontrol. See Customizing QToolBar for an example. 支持盒子模型。 :top, :left, :right, :bottom 伪状态取决于工具栏所在的区域。 :first、:last、:middle、:only-one 伪状态指示线组中工具栏的位置(请参阅 QStyleOptionToolBar::positionWithinLine)。 QToolBar 的分隔符使用 ::separator 子控件进行样式设置。 手柄(用于移动工具栏)使用 ::handle 子控件设置样式。 有关示例,请参阅自定义 QToolBar。 |
QToolButton | Supports the box model. If the QToolButton has a menu, is ::menu-indicator subcontrol can be used to style the indicator. By default, the menu-indicator is positioned at the bottom right of the Padding rectangle of the widget. If the QToolButton is in QToolButton::MenuButtonPopup mode, the ::menu-button subcontrol is used to draw the menu button. ::menu-arrow subcontrol is used to draw the menu arrow inside the menu-button. By default, it is positioned in the center of the Contents rectangle of the menu-button subcontrol. When the QToolButton displays arrows, the ::up-arrow, ::down-arrow, ::left-arrow and ::right-arrow subcontrols are used. Warning: If you only set a background-color on a QToolButton, the background will not appear unless you set the border property to some value. This is because, by default, the QToolButton draws a native border which completely overlaps the background-color. For example, See Customizing QToolButton for an example. 支持盒子模型。 如果 QToolButton 有菜单, is ::menu-indicator 子控件可用于设置指示器的样式。默认情况下,菜单指示器位于小部件的 Padding 矩形的右下角。 如果 QToolButton 处于 QToolButton::MenuButtonPopup 模式,则使用 ::menu-button 子控件绘制菜单按钮。 ::menu-arrow 子控件用于在菜单按钮内绘制菜单箭头。默认情况下,它位于菜单按钮子控件的内容矩形的中心。 当 QToolButton 显示箭头时,会使用 ::up-arrow、::down-arrow、::left-arrow 和 ::right-arrow 子控件。 警告:如果您只在 QToolButton 上设置背景颜色,除非您将边框属性设置为某个值,否则背景不会出现。这是因为默认情况下,QToolButton 会绘制一个与背景颜色完全重叠的原生边框。例如, QToolButton { background-color: red; border: none; }有关示例,请参阅自定义 QToolButton。 |
QToolBox | Supports the box model. The individual tabs can by styled using the ::tab subcontrol. The tabs support the :only-one, :first, :last, :middle, :previous-selected, :next-selected, :selected pseudo states. 支持盒子模型。 可以使用 ::tab 子控件设置各个选项卡的样式。 选项卡支持:only-one, :first, :last, :middle, :previous-selected, :next-selected, :selected 伪状态。 |
QToolTip | Supports the box model. The opacity property controls the opacity of the tooltip. See Customizing QFrame for an example (a QToolTip is a QFrame). 支持盒子模型。 opacity 属性控制工具提示的不透明度。 有关示例,请参阅自定义 QFrame(QToolTip 是 QFrame)。 |
QTreeView | Supports the box model. When alternating row colors is enabled, the alternating colors can be styled using the alternate-background-color property. The color and background of the selected item is styled using selection-color and selection-background-color respectively. The selection behavior is controlled by the show-decoration-selected property. The branches of the tree view can be styled using the ::branch subcontrol. The ::branch Sub-control supports the :open, :closed, :has-sibling and :has-children pseudo states. Use the ::item subcontrol for more fine grained control over the items in the QTreeView. See QAbsractScrollArea to style scrollable backgrounds. See Customizing QTreeView for an example to style the branches. 支持盒子模型。 启用交替行颜色后,可以使用交替背景颜色属性设置交替颜色的样式。 所选项目的颜色和背景分别使用 selection-color 和 selection-background-color 设置样式。 选择行为由 show-decoration-selected 属性控制。 树视图的分支可以使用 ::branch 子控件进行样式设置。 ::branch 子控件支持 :open、:closed、:has-sibling 和 :has-children 伪状态。 使用 ::item 子控件对 QTreeView 中的项目进行更细粒度的控制。 请参阅 QAbsractScrollArea 以设置可滚动背景的样式。 有关设置分支样式的示例,请参阅自定义 QTreeView。 |
QTreeWidget | See QTreeView. |
QWidget | Supports only the background, background-clip and background-origin properties. If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below: 仅支持背景、背景剪辑和背景原点属性。 如果您是 QWidget 的子类,则需要为您的自定义 QWidget 提供一个paintEvent,如下所示: The above code is a no-operation if there is no stylesheet set. Warning: Make sure you define the Q_OBJECT macro for your custom widget. 如果没有设置样式表,上面的代码是无操作的。 警告:确保为自定义小部件定义 Q_OBJECT 宏。 |
The table below lists all the properties supported by Qt Style Sheets. Which values can be given to an property depend on the property's type. Unless otherwise specified, properties below apply to all widgets. Properties marked with an asterisk * are specific to Qt and have no equivalent in CSS2 or CSS3.
下表列出了 Qt 样式表支持的所有属性。 可以为属性赋予哪些值取决于属性的类型。 除非另有说明,否则以下属性适用于所有小部件。 用星号 * 标记的属性是 Qt 特有的,在 CSS2 或 CSS3 中没有等效项。
属性 | 类型 | 描述 |
---|---|---|
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: QAbstractItemView 子类中使用的备用背景颜色。 如果未设置此属性, 则默认值是为调色板的 AlternateBase 角色设置的任何值。 例子: 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/or background-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: 用于设置背景的速记符号。 相当于指定背景颜色、背景图像、背景重复和/或背景位置。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QDialog、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTWidget 支持此属性 例子: 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: 通常,需要设置类似于 Qt::BrushStyle 中的样式的填充模式。 您可以为 Qt::SolidPattern、Qt::RadialGradientPattern、Qt::LinearGradientPattern 和 Qt::ConicalGradientPattern 使用背景颜色属性。 通过创建包含该图案的背景图像,可以轻松实现其他图案。 例子: See also background-origin, selection-background-color, background-clip, background-attachment and alternate-background-color. |
background-color |
Brush | The background color used for the widget. Examples: 用于小部件的背景颜色。 例子: |
background-image |
Url | The background image used for the widget. Semi-transparent parts of the image let the background-color shine through. Example: 用于小部件的背景图像。 图像的半透明部分让背景颜色闪耀。 例子: |
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 ( Example: 是否以及如何重复背景图像以填充背景原点矩形。 如果未指定此属性,则背景图像在两个方向上重复(repeat)。 例子: |
background-position |
Alignment | The alignment of the background image within the background-origin rectangle. If this property is not specified, the alignment is Example: 背景图片在背景原点矩形内的对齐方式。 如果未指定此属性,则对齐方式为左上角。 例子: |
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: 确定 QAbstractScrollArea 中的背景图像是相对于视口滚动还是固定。 默认情况下,背景图像随视口滚动。 例子: See also background |
background-clip |
Origin | The widget's rectangle, in which the background is drawn. This property specifies the rectangle to which the 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 Example: 小部件的矩形,其中绘制了背景。 此属性指定背景颜色和背景图像被剪切到的矩形。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QDialog、QFrame、QGroupBox、QLabel、QPushButton、QRadioButton、QSplitter、QTextEdit、QToolTip 和普通 QWidget 支持此属性。 如果未指定此属性,则默认为边框。 例子: See also background, background-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, QCheckBox, QComboBox, QDialog, QFrame, QGroupBox, QLabel, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. If this property is not specified, the default is Example: 小部件的背景矩形,与背景位置和背景图像结合使用。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QDialog、QFrame、QGroupBox、QLabel、QPushButton、QRadioButton、QSplitter、QTextEdit、QToolTip 和普通 QWidget 支持此属性。 如果未指定此属性,则默认为填充。 例子: 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, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip, and plain QWidgets. Example: 用于设置小部件边框的速记符号。 相当于指定边框颜色、边框样式和/或边框宽度。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit、QToolQWidgets 和普通支持此属性。 例子: |
border-top |
Border | Shorthand notation for setting the widget's top border. Equivalent to specifying 用于设置小部件顶部边框的速记符号。 相当于指定 border-top-color、border-top-style 和/或 border-top-width。 |
border-right |
Border | Shorthand notation for setting the widget's right border. Equivalent to specifying 用于设置小部件右边框的速记符号。 相当于指定 border-right-color、border-right-style 和/或 border-right-width。 |
border-bottom |
Border | Shorthand notation for setting the widget's bottom border. Equivalent to specifying 用于设置小部件底部边框的速记符号。 相当于指定 border-bottom-color、border-bottom-style 和/或 border-bottom-width。 |
border-left |
Border | Shorthand notation for setting the widget's left border. Equivalent to specifying 用于设置小部件左边框的速记符号。 相当于指定border-left-color、border-left-style和/或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, 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: 所有边框边缘的颜色。 相当于指定border-top-color、border-right-color、border-bottom-color和border-left-color。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit、QToolQWidgets 和普通支持此属性。 如果未指定此属性,则默认为颜色(即小部件的前景色)。 例子: See also border-style, border-width, border-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, 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. 用于填充边框的图像。 图像被切割成九个部分,并在必要时适当拉伸。 有关详细信息,请参阅边框图片。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 另请参阅边框颜色、边框样式、边框宽度和盒子模型。 |
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, 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: 边界角的半径。 相当于指定border-top-left-radius、border-top-right-radius、border-bottom-right-radius和border-bottom-left-radius。 border-radius 剪辑元素的背景。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 如果未指定此属性,则默认为 0。 例子: 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, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to Example: 所有边框边缘的样式。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 如果未指定此属性,则默认为无。 例子: See also border-color, border-style, border-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, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. Example: 边框的宽度。 相当于设置border-top-width、border-right-width、border-bottom-width和border-left-width。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 例子: See also border-color, border-radius, border-style, border-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 Example: 如果位置是相对的(默认),则将子控件向上移动一定的偏移量; 指定底部:y 则等效于指定顶部:-y。 如果 position 是绝对的,则底部属性指定子控件相对于父控件底部边缘的底部边缘(另请参阅 subcontrol-origin)。 例子: 如果位置是相对的(默认),则将子控件向上移动一定的偏移量; 指定底部:y 则等效于指定顶部:-y。 如果 position 是绝对的,则底部属性指定子控件相对于父控件底部边缘的底部边缘(另请参阅 subcontrol-origin)。 例子: QSpinBox::down-button { bottom: 2px } See also left, right, 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), 3 (GnomeLayout) and 5 (AndroidLayout). If this property is not specified, it defaults to the value specified by the current style for the SH_DialogButtonLayout style hint. Example: QDialogButtonBox 或 QMessageBox 中按钮的布局。 可能的值为 0 (WinLayout)、1 (MacLayout)、2 (KdeLayout)、3 (GnomeLayout) 和 5 (AndroidLayout)。 如果未指定此属性,则默认为 SH_DialogButtonLayout 样式提示的当前样式指定的值。 例子: |
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: 用于呈现文本的颜色。 所有尊重 QWidget::palette 的小部件都支持此属性。 如果未设置此属性,则默认值为小部件调色板中为 QWidget::foregroundRole 设置的任何内容(通常为黑色)。 例子: 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. 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. QDialogButtonBox 中的按钮是否显示图标 如果此属性设置为 1,则 QDialogButtonBox 的按钮显示图标; 如果设置为 0,则不显示图标。 有关如何设置图标的信息,请参阅图标列表部分。 QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 1; } 注意:定义此属性的样式必须在创建 QDialogButtonBox 之前应用; 这意味着您必须将样式应用到父小部件或应用程序本身。 |
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: 用于设置文本字体的速记符号。 相当于指定 font-family、font-size、font-style 和/或 font-weight。 所有尊重 QWidget::font 的小部件都支持此属性。 如果未设置此属性,则默认为 QWidget::font。 例子: |
font-family |
String | The font family.字体家族。 Example: |
font-size |
Font Size | The font size. In this version of Qt, only pt and px metrics are supported. 字体大小。 在此版本的 Qt 中,仅支持 pt 和 px 指标。 Example: |
font-style |
Font Style | The font style.字体样式。 Example: |
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: QTableView 中网格线的颜色。 如果未指定此属性,则默认为当前样式为 SH_Table_GridLineColor 样式提示指定的值。 例子: |
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. 子控件(或在某些情况下是小部件)的高度。 如果未指定此属性,则默认为取决于子控件/小部件和当前样式的值。 警告:除非另有说明,否则此属性在小部件上设置时无效。 如果您想要一个具有固定高度的小部件,请将 min-height 和 max-height 设置为相同的值。 Example: See also width. |
icon |
Url+ | The icon that is used, for widgets that have an icon. The only widget currently supporting this property is QPushButton. Note: It's the application's responsibilty to assign an icon to a button (using the QAbstractButton API), and not the style's. So be careful setting it unless your stylesheet is targeting a specific application. Available since 5.15. 用于具有图标的小部件的图标。 当前唯一支持此属性的小部件是 QPushButton。 注意:为按钮分配图标(使用 QAbstractButton API)是应用程序的责任,而不是样式的责任。 因此,除非您的样式表针对特定应用程序,否则请小心设置它。 自 5.15 起可用。 |
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. 小部件中图标的宽度和高度。 可以使用此属性设置以下小部件的图标大小。
|
image * |
Url+ | The image that is drawn in the contents rectangle of a subcontrol. The image property accepts a list of Urls or an 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. 在子控件的内容矩形中绘制的图像。 image 属性接受 URL 列表或 svg。 绘制的实际图像使用与 QIcon 相同的算法确定(即图像从不放大,但在必要时总是缩小。 如果指定了 svg,则图像将缩放到内容矩形的大小。 在子控件上设置图像属性会隐式设置子控件的宽度和高度(除非图像在 SVG 中)。 在 Qt 4.3 及更高版本中,可以使用 image-position 指定矩形内图像的对齐方式。 此属性仅适用于子控件——我们不支持其他元素使用它。 警告:渲染 SVG 图像需要 QIcon SVG 插件。 Example: |
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. 在 Qt 4.3 及更高版本中,可以使用相对或绝对位置指定图像图像位置的对齐方式。 |
left |
Length | If position is relative (the default), moves a subcontrol by a certain offset to the right. If position is If this property is not specified, it defaults to 如果 position 是相对的(默认),则将子控件向右移动一定的偏移量。 如果 position 是绝对的,则 left 属性指定子控件相对于父控件左边缘的左边缘(另请参阅 subcontrol-origin)。 如果未指定此属性,则默认为 0。 Example: See also right, top, 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. QLineEdit 密码字符作为 Unicode 数字。 如果未指定此属性,则默认为 SH_LineEdit_PasswordCharacter 样式提示的当前样式指定的值。 Example: |
lineedit-password-mask-delay* |
Number | The QLineEdit password mask delay in milliseconds before lineedit-password-character is applied to visible character. If this property is not specified, it defaults to the value specified by the current style for the SH_LineEdit_PasswordMaskDelay style hint. This property was added in Qt 5.4. 在将 lineedit-password-character 应用于可见字符之前,QLineEdit 密码掩码延迟(以毫秒为单位)。 如果未指定此属性,则默认为 SH_LineEdit_PasswordMaskDelay 样式提示的当前样式指定的值。 这个属性是在 Qt 5.4 中添加的。 Example: |
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, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to 小部件的边距。 相当于指定 margin-top、margin-right、margin-bottom 和 margin-left。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 如果未指定此属性,则默认为 0。 Example: See also padding, spacing, 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, 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. 小部件或子控件的最大高度。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSizeGrip、QSpinBox、QTextEdit、QStatus、QStatus 支持此属性。 该值与框模型中的内容 rect 相关。 Example: 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, 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. 小部件或子控件的最大宽度。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSizeGrip、QSpinBox、QTextEdit、QStatus、QStatus 支持此属性。 该值与框模型中的内容 rect 相关。
Example: 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. 消息框中文本的交互行为。 可能的值基于 Qt::TextInteractionFlags。 如果未指定此属性,则默认为当前样式为 SH_MessageBox_TextInteractionFlags 样式提示指定的值。 Example: |
min-height |
Length | 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. 小部件或子控件的最小高度。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSizeGrip、QSpinBox、QTextEdit、QStatus、QStatus 支持此属性。 如果未指定此属性,则根据小部件的内容和样式得出最小高度。 该值与框模型中的内容 rect 相关。 Example: 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, 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. 小部件或子控件的最小宽度。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSizeGrip、QSpinBox、QTextEdit、QStatus、QStatus 支持此属性。 如果未指定此属性,则根据小部件的内容和样式派生最小宽度。 该值与框模型中的内容 rect 相关。 Example: 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. 小部件的不透明度。 可能的值是从 0(透明)到 255(不透明)。 目前,这仅支持工具提示。 如果未指定此属性,则默认为 SH_ToolTipLabel_Opacity 样式提示的当前样式指定的值。 Example: |
outline | The outline drawn around the object's border.围绕对象边框绘制的轮廓。 | |
outline-color | Color | The color of the outline. See also border-color轮廓的颜色。 另请参阅边框颜色 |
outline-offset | Length | The outline's offset from the border of the widget.轮廓与小部件边框的偏移量。 |
outline-style | Specifies the pattern used to draw the outline. See also border-style 指定用于绘制轮廓的图案。 另请参阅边框样式 |
|
outline-radius | Adds rounded corners to the outline为轮廓添加圆角 | |
outline-bottom-left-radius | Radius | The radius for the bottom-left rounded corner of the outline. 轮廓左下角圆角的半径。 |
outline-bottom-right-radius | Radius | The radius for the bottom-right rounded corner of the outline. 轮廓右下角圆角的半径。 |
outline-top-left-radius | Radius | The radius for the top-left corner of the outline. 轮廓左上角的半径。 |
outline-top-right-radius | Radius | The radius for the top-right rounded corner of the outline. 轮廓右上角圆角的半径。 |
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, QCheckBox, QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit, and QToolTip. If this property is not specified, it defaults to 小部件的填充。 相当于指定 padding-top、padding-right、padding-bottom 和 padding-left。 QAbstractItemView 子类、QAbstractSpinBox 子类、QCheckBox、QComboBox、QFrame、QGroupBox、QLabel、QLineEdit、QMenu、QMenuBar、QPushButton、QRadioButton、QSplitter、QTextEdit 和 QToolTip 支持此属性。 如果未指定此属性,则默认为 0。 Example: See also margin, spacing, 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) QTreeView 是否为空白区域(即没有项目的区域)绘制交替的行颜色 |
position |
relative | absolute |
Whether offsets specified using left, right, top, and bottom are relative or absolute coordinates. If this property is not specified, it defaults to 使用左、右、顶和底指定的偏移量是相对坐标还是绝对坐标。 如果未指定此属性,则默认为相对。 |
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 如果 position 是相对的(默认),则将子控件向左移动一定的偏移量; 指定 right: x 等效于指定 left: -x。 如果 position 是绝对的, 则 right 属性指定子控件相对于父控件右边缘的右边缘(另请参阅 subcontrol-origin)。 Example: See also left, top, 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. 所选文本或项目的背景。 所有尊重 QWidget::palette 并显示选择文本的小部件都支持此属性。 如果未设置此属性,则默认值是为调色板的突出显示角色设置的任何值。 Example: 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. 所选文本或项目的前景。 所有尊重 QWidget::palette 并显示选择文本的小部件都支持此属性。 如果未设置此属性, 则默认值是为调色板的 HighlightedText 角色设置的任何值。 Example: 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. 控制 QListView 中的选择是覆盖整行还是仅覆盖文本的范围。 如果未指定此属性, 则默认为 SH_ItemView_ShowDecorationSelected 样式提示的当前样式指定的值。 Example: |
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. 小部件中的内部间距。 QCheckBox、可检查的 QGroupBoxes、QMenuBar 和 QRadioButton 支持此属性。 如果未指定此属性,则默认值取决于小部件和当前样式。 Example: 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 父元素内子控件的原点矩形。 如果未指定此属性,则默认为填充。 Example: 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. 子控件在 subcontrol-origin 指定的原点矩形内的对齐方式。 如果未指定此属性,则默认为取决于子控件的值。 Example: See also subcontrol-origin. |
titlebar-show-tooltips-on-buttons } |
bool |
Whether tool tips are shown on window title bar buttons. 工具提示是否显示在窗口标题栏按钮上。 |
widget-animation-duration* |
Number | How much an animation should last (in milliseconds). A value equal to zero means that the animations will be disabled. If this property is not specified, it defaults to the value specified by the current style for the SH_Widget_Animation_Duration style hint. This property was added in Qt 5.10. 动画应该持续多长时间(以毫秒为单位)。 值为零意味着动画将被禁用。 如果未指定此属性, 则默认为 SH_Widget_Animation_Duration 样式提示的当前样式指定的值。 这个属性是在 Qt 5.10 中添加的。 Example: |
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: 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 If this property is not specified, it defaults to 如果 position 是相对的(默认),则将子控件向下移动一定的偏移量。 如果 position 是绝对的,则 top 属性指定子控件相对于父控件的顶部边缘的顶部边缘 (另请参阅 subcontrol-origin)。 如果未指定此属性,则默认为 0。 Example: See also left, right, 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. 子控件(或某些情况下的小部件)的宽度。 如果未指定此属性,则默认为取决于子控件/小部件和当前样式的值。 警告:除非另有说明,否则此属性在小部件上设置时无效。 如果您想要一个固定宽度的小部件,请将 min-width 和 max-width 设置为相同的值。
Example: See also height. |
-qt-background-role | PaletteRole | The 基于所选角色的子控件或小部件的背景颜色。 |
-qt-style-features | list |
The list of CSS properties that you want to apply Qt-specific styles on. Note: The 要应用 Qt 特定样式的 CSS 属性列表。 注意:该列表只能包含不基于像素图的属性。 |
Qt中使用的图标可以使用以下属性进行自定义。本节中列出的每个属性都有类型图标。
请注意,要使图标出现在 QDialogButtonBox 的按钮中,您需要将 dialogbuttonbox-buttons-have-icons 属性设置为 true。 此外,要自定义图标的大小,请使用 icon-size 属性。
Name | QStyle::StandardPixmap |
---|---|
backward-icon | QStyle::SP_ArrowBack |
cd-icon | QStyle::SP_DriveCDIcon |
computer-icon | QStyle::SP_ComputerIcon |
desktop-icon | QStyle::SP_DesktopIcon |
dialog-apply-icon | QStyle::SP_DialogApplyButton |
dialog-cancel-icon | QStyle::SP_DialogCancelButton |
dialog-close-icon | QStyle::SP_DialogCloseButton |
dialog-discard-icon | QStyle::SP_DialogDiscardButton |
dialog-help-icon | QStyle::SP_DialogHelpButton |
dialog-no-icon | QStyle::SP_DialogNoButton |
dialog-ok-icon | QStyle::SP_DialogOkButton |
dialog-open-icon | QStyle::SP_DialogOpenButton |
dialog-reset-icon | QStyle::SP_DialogResetButton |
dialog-save-icon | QStyle::SP_DialogSaveButton |
dialog-yes-icon | QStyle::SP_DialogYesButton |
directory-closed-icon | QStyle::SP_DirClosedIcon |
directory-icon | QStyle::SP_DirIcon |
directory-link-icon | QStyle::SP_DirLinkIcon |
directory-open-icon | QStyle::SP_DirOpenIcon |
dockwidget-close-icon | QStyle::SP_DockWidgetCloseButton |
downarrow-icon | QStyle::SP_ArrowDown |
dvd-icon | QStyle::SP_DriveDVDIcon |
file-icon | QStyle::SP_FileIcon |
file-link-icon | QStyle::SP_FileLinkIcon |
filedialog-contentsview-icon | QStyle::SP_FileDialogContentsView |
filedialog-detailedview-icon | QStyle::SP_FileDialogDetailedView |
filedialog-end-icon | QStyle::SP_FileDialogEnd |
filedialog-infoview-icon | QStyle::SP_FileDialogInfoView |
filedialog-listview-icon | QStyle::SP_FileDialogListView |
filedialog-new-directory-icon | QStyle::SP_FileDialogNewFolder |
filedialog-parent-directory-icon | QStyle::SP_FileDialogToParent |
filedialog-start-icon | QStyle::SP_FileDialogStart |
floppy-icon | QStyle::SP_DriveFDIcon |
forward-icon | QStyle::SP_ArrowForward |
harddisk-icon | QStyle::SP_DriveHDIcon |
home-icon | QStyle::SP_DirHomeIcon |
leftarrow-icon | QStyle::SP_ArrowLeft |
messagebox-critical-icon | QStyle::SP_MessageBoxCritical |
messagebox-information-icon | QStyle::SP_MessageBoxInformation |
messagebox-question-icon | QStyle::SP_MessageBoxQuestion |
messagebox-warning-icon | QStyle::SP_MessageBoxWarning |
network-icon | QStyle::SP_DriveNetIcon |
rightarrow-icon | QStyle::SP_ArrowRight |
titlebar-contexthelp-icon | QStyle::SP_TitleBarContextHelpButton |
titlebar-maximize-icon | QStyle::SP_TitleBarMaxButton |
titlebar-menu-icon | QStyle::SP_TitleBarMenuButton |
titlebar-minimize-icon | QStyle::SP_TitleBarMinButton |
titlebar-normal-icon | QStyle::SP_TitleBarNormalButton |
titlebar-shade-icon | QStyle::SP_TitleBarShadeButton |
titlebar-unshade-icon | QStyle::SP_TitleBarUnshadeButton |
trash-icon | QStyle::SP_TrashIcon |
uparrow-icon | QStyle::SP_ArrowUp |
下表总结了不同属性类型的语法和含义。
Type | Syntax | Description |
---|---|---|
Alignment | { top | bottom | left | right | center }* |
Horizontal and/or vertical alignment. Example: QTextEdit { background-position: bottom center } |
Attachment | { scroll | fixed }* |
Scroll or fixed attachment. |
Background | { Brush | Url | Repeat | Alignment }* |
A sequence of Brush, Url, Repeat, and Alignment. |
Boolean | 0 | 1 | True (1 ) or false (0 ). Example: QDialog { etch-disabled-text: 1 } |
Border | { Border Style | Length | Brush }* |
Shorthand border property. |
Border Image | none | Url Number{4} ( stretch | repeat ){0,2} |
边框图像是由九个部分组成的图像(左上、中上、右上、左中、中、右中、左下、中下和右下)。当需要一定尺寸的边框时,角部按原样使用,顶部、右侧、底部和左侧部分拉伸或重复以生成所需尺寸的边框。 See the CSS3 Draft Specification for details. |
Border Style | dashed | dot-dash | dot-dot-dash | dotted | double | groove | inset | outset | ridge | solid | none |
Specifies the pattern used to draw a border. See the CSS3 Draft Specification for details.指定用于绘制边框的图案。 有关详细信息,请参阅 CSS3 草案规范。 |
Box Colors | Brush{1,4} | 一到四次 笔刷,分别指定长方体的上、右、下和左边缘。如果未指定左颜色,则认为它与右颜色相同。如果未指定底色,则认为底色与顶色相同。如果未指定正确的颜色,则视为与顶部颜色相同。 Example: QLabel { border-color: red } /* red red red red */ QLabel { border-color: red blue } /* red blue red blue */ QLabel { border-color: red blue green } /* red blue green blue */ QLabel { border-color: red blue green yellow } /* red blue green yellow */ |
Box Lengths | Length{1,4} | One to four occurrences of Length, specifying the top, right, bottom, and left edges of a box, respectively. If the left length is not specified, it is taken to be the same as the right length. If the bottom length is not specified, is it taken to be the same as the top length. If the right length is not specified, it is taken to be the same as the top length. Examples: QLabel { border-width: 1px } /* 1px 1px 1px 1px */ QLabel { border-width: 1px 2px } /* 1px 2px 1px 2px */ QLabel { border-width: 1px 2px 3px } /* 1px 2px 3px 2px */ QLabel { border-width: 1px 2px 3px 4px } /* 1px 2px 3px 4px */ |
Brush | Color | Gradient | PaletteRole |
Specifies a Color or a Gradient or an entry in the Palette. |
Color | rgb(r, g, b) | rgba(r, g, b, a) | hsv(h, s, v) | hsva(h, s, v, a) | hsl(h, s, l) | hsla(h, s, l, a) | #rrggbb | Color Name |
Specifies a color as RGB (red, green, blue), RGBA (red, green, blue, alpha), HSV (hue, saturation, value), HSVA (hue, saturation, value, alpha), HSL (hue, saturation, lightness), HSLA (hue, saturation, lightness, alpha) or a named color. The rgb() or rgba() syntax can be used with integer values between 0 and 255, or with percentages. The value of s, v, l and a in hsv() , hsva() hsl() or hsla() must all be in the range 0-255 or with percentages, the value of h must be in the range 0-359. The support for HSL(A) is available since 5.13. Examples: QLabel { border-color: red } /* opaque red */ QLabel { border-color: #FF0000 } /* opaque red */ QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */ QLabel { border-color: rgb(255, 0, 0) } /* opaque red */ QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */ QLabel { border-color: hsv(60, 100%, 100%) } /* opaque yellow */ QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */ QLabel { border-color: hsl(60, 100%, 50%) } /* opaque yellow */ QLabel { border-color: hsla(240, 255, 50%, 75%) } /* 75% blue */ Note: The RGB colors allowed are the same as those allowed with CSS 2.1, as listed here. |
Font | (Font Style | Font Weight){0,2} Font Size String | Shorthand font property. |
Font Size | Length | The size of a font. |
Font Style | normal | italic | oblique |
The style of a font. |
Font Weight | normal | bold | 100 | 200 ... | 900 |
The weight of a font. |
Gradient | qlineargradient | qradialgradient | qconicalgradient |
Specifies gradient fills. There are three types of gradient fills:
Gradients are specified in Object Bounding Mode. Imagine the box in which the gradient is rendered, to have its top left corner at (0, 0) and its bottom right corner at (1, 1). Gradient parameters are then specified as percentages from 0 to 1. These values are extrapolated to actual box coordinates at runtime. It is possible specify values that lie outside the bounding box (-0.6 or 1.8, for instance). Warning: The stops have to appear sorted in ascending order. Examples: /* linear gradient from white to green */ QTextEdit { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 white, stop: 0.4 gray, stop:1 green) } /* linear gradient from white to green */ QTextEdit { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 white, stop: 0.4 rgba(10, 20, 30, 40), stop:1 rgb(0, 200, 230, 200)) } /* conical gradient from white to green */ QTextEdit { background: qconicalgradient(cx:0.5, cy:0.5, angle:30, stop:0 white, stop:1 #00FF00) } /* radial gradient from white to green */ QTextEdit { background: qradialgradient(cx:0, cy:0, radius: 1, fx:0.5, fy:0.5, stop:0 white, stop:1 green) } |
Icon | (Url (disabled | active | normal | selected )? (on | off )? )* |
A list of url, QIcon::Mode and QIcon::State. Example: * { file-icon: url(file.png), url(file_selected.png) selected; } QMessageBox { dialogbuttonbox-buttons-have-icons: true; dialog-ok-icon: url(ok.svg); dialog-cancel-icon: url(cancel.png), url(grayed_cancel.png) disabled; } |
Length | Number (px | pt | em | ex )? |
A number followed by a measurement unit. The CSS standard recommends that user agents must ignore a declaration with an illegal value. In Qt, it is mandatory to specify measurement units. For compatibility with earlier versions of Qt, numbers without measurement units are treated as pixels in most contexts. The supported units are:
However, Qt is limited to font sizes in |
Number | A decimal integer or a real number | Examples: 0 , 18 , +127 , -255 , 12.34 , -.5 , 0009 . |
Origin | margin | border | padding | content |
Indicates which of four rectangles to use.
See also The Box Model. |
PaletteRole | alternate-base | base | bright-text | button | button-text | dark | highlight | highlighted-text | light | link | link-visited | mid | midlight | shadow | text | window | window-text |
These values correspond the Color roles in the widget's QPalette. For example, QPushButton { color: palette(dark); } |
Radius | Length{1, 2} | One or two occurrences of Length. If only one length is specified, it is used as the radius of the quarter circle defining the corner. If two lengths are specified, the first length is the horizontal radius of a quarter ellipse, whereas the second length is the vertical radius. |
Repeat | repeat-x | repeat-y | repeat | no-repeat |
A value indicating the nature of repetition.
|
Url | url(filename) |
filename is the name of a file on the local disk or stored using The Qt Resource System. Setting an image implicitly sets the width and height of the element. |
支持以下伪状态::
Pseudo-State | Description |
---|---|
:active |
This state is set when the widget resides in an active window. |
:adjoins-item |
This state is set when the ::branch of a QTreeView is adjacent to an item. |
:alternate |
This state is set for every alternate row whe painting the row of a QAbstractItemView when QAbstractItemView::alternatingRowColors() is set to true. |
:bottom |
The item is positioned at the bottom. For example, a QTabBar that has its tabs positioned at the bottom. |
:checked |
The item is checked. For example, the checked state of QAbstractButton. |
:closable |
The items can be closed. For example, the QDockWidget has the QDockWidget::DockWidgetClosable feature turned on. |
:closed |
The item is in the closed state. For example, an non-expanded item in a QTreeView |
:default |
The item is the default. For example, a default QPushButton or a default action in a QMenu. |
:disabled |
The item is disabled. |
:editable |
The QComboBox is editable. |
:edit-focus |
The item has edit focus (See QStyle::State_HasEditFocus). This state is available only for Qt Extended applications. |
:enabled |
The item is enabled. |
:exclusive |
The item is part of an exclusive item group. For example, a menu item in a exclusive QActionGroup. |
:first |
The item is the first (in a list). For example, the first tab in a QTabBar. |
:flat |
The item is flat. For example, a flat QPushButton. |
:floatable |
The items can be floated. For example, the QDockWidget has the QDockWidget::DockWidgetFloatable feature turned on. |
:focus |
The item has input focus. |
:has-children |
The item has children. For example, an item in a QTreeView that has child items. |
:has-siblings |
The item has siblings. For example, an item in a QTreeView that siblings. |
:horizontal |
The item has horizontal orientation |
:hover |
The mouse is hovering over the item. |
:indeterminate |
The item has indeterminate state. For example, a QCheckBox or QRadioButton is partially checked. |
:last |
The item is the last (in a list). For example, the last tab in a QTabBar. |
:left |
The item is positioned at the left. For example, a QTabBar that has its tabs positioned at the left. |
:maximized |
The item is maximized. For example, a maximized QMdiSubWindow. |
:middle |
The item is in the middle (in a list). For example, a tab that is not in the beginning or the end in a QTabBar. |
:minimized |
The item is minimized. For example, a minimized QMdiSubWindow. |
:movable |
The item can be moved around. For example, the QDockWidget has the QDockWidget::DockWidgetMovable feature turned on. |
:no-frame |
The item has no frame. For example, a frameless QSpinBox or QLineEdit. |
:non-exclusive |
The item is part of a non-exclusive item group. For example, a menu item in a non-exclusive QActionGroup. |
:off |
For items that can be toggled, this applies to items in the "off" state. |
:on |
For items that can be toggled, this applies to widgets in the "on" state. |
:only-one |
The item is the only one (in a list). For example, a lone tab in a QTabBar. |
:open |
The item is in the open state. For example, an expanded item in a QTreeView, or a QComboBox or QPushButton with an open menu. |
:next-selected |
The next item (in a list) is selected. For example, the selected tab of a QTabBar is next to this item. |
:pressed |
The item is being pressed using the mouse. |
:previous-selected |
The previous item (in a list) is selected. For example, a tab in a QTabBar that is next to the selected tab. |
:read-only |
The item is marked read only or non-editable. For example, a read only QLineEdit or a non-editable QComboBox. |
:right |
The item is positioned at the right. For example, a QTabBar that has its tabs positioned at the right. |
:selected |
The item is selected. For example, the selected tab in a QTabBar or the selected item in a QMenu. |
:top |
The item is positioned at the top. For example, a QTabBar that has its tabs positioned at the top. |
:unchecked |
The item is unchecked. |
:vertical |
The item has vertical orientation. |
:window |
The widget is a window (i.e top level widget) |
以下子控件可用:
Sub-Control | Description |
---|---|
::add-line |
The button to add a line of a QScrollBar. |
::add-page |
The region between the handle (slider) and the add-line of a QScrollBar. |
::branch |
The branch indicator of a QTreeView. |
::chunk |
The progress chunk of a QProgressBar. |
::close-button |
The close button of a QDockWidget or tabs of QTabBar |
::corner |
The corner between two scrollbars in a QAbstractScrollArea |
::down-arrow |
The down arrow of a QComboBox, QHeaderView (sort indicator), QScrollBar or QSpinBox. |
::down-button |
The down button of a QScrollBar or a QSpinBox. |
::drop-down |
The drop-down button of a QComboBox. |
::float-button |
The float button of a QDockWidget |
::groove |
The groove of a QSlider. |
::indicator |
The indicator of a QAbstractItemView, a QCheckBox, a QRadioButton, a checkable QMenu item or a checkable QGroupBox. |
::handle |
The handle (slider) of a QScrollBar, a QSplitter, or a QSlider. |
::icon |
The icon of a QAbstractItemView or a QMenu. |
::item |
An item of a QAbstractItemView, a QMenuBar, a QMenu, or a QStatusBar. |
::left-arrow |
The left arrow of a QScrollBar. |
::left-corner |
The left corner of a QTabWidget. For example, this control can be used to control position the left corner widget in a QTabWidget. |
::menu-arrow |
The arrow of a QToolButton with a menu. |
::menu-button |
The menu button of a QToolButton. |
::menu-indicator |
The menu indicator of a QPushButton. |
::right-arrow |
The right arrow of a QMenu or a QScrollBar. |
::pane |
The pane (frame) of a QTabWidget. |
::right-corner |
The right corner of a QTabWidget. For example, this control can be used to control the position the right corner widget in a QTabWidget. |
::scroller |
The scroller of a QMenu or QTabBar. |
::section |
The section of a QHeaderView. |
::separator |
The separator of a QMenu or in a QMainWindow. |
::sub-line |
The button to subtract a line of a QScrollBar. |
::sub-page |
The region between the handle (slider) and the sub-line of a QScrollBar. |
::tab |
The tab of a QTabBar or QToolBox. |
::tab-bar |
The tab bar of a QTabWidget. This subcontrol exists only to control the position of the QTabBar inside the QTabWidget. To style the tabs using the ::tab subcontrol. |
::tear |
The tear indicator of a QTabBar. |
::tearoff |
The tear-off indicator of a QMenu. |
::text |
The text of a QAbstractItemView. |
::title |
The title of a QGroupBox or a QDockWidget. |
::up-arrow |
The up arrow of a QHeaderView (sort indicator), QScrollBar or a QSpinBox. |
::up-button |
The up button of a QSpinBox. |