Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI. More...
#include <QStyle>
Inherits QObject.
Inherited by QCommonStyle.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Qt contains a set of QStyle subclasses that emulate the styles of the different platforms supported by Qt (QWindowsStyle, QMacStyle, QMotifStyle, etc.). By default, these styles are built into the QtGui library. Styles can also be made available as plugins.
Qt's built-in widgets use QStyle to perform nearly all of their drawing, ensuring that they look exactly like the equivalent native widgets. The diagram below shows a QComboBox in eight different styles.
Topics:
The style of the entire application can be set using QApplication::setStyle(). It can also be specified by the user of the application, using the -style command-line option:
./myapplication -style motif
If no style is specified, Qt will choose the most appropriate style for the user's platform or desktop environment.
A style can also be set on an individual widget using QWidget::setStyle().
If you are developing custom widgets and want them to look good on all platforms, you can use QStyle functions to perform parts of the widget drawing, such as drawItem(), drawPrimitive(), drawControl(), and drawComplexControl().
Most QStyle draw functions take four arguments:
For example, if you want to draw a focus rectangle on your widget, you can write:
void MyWidget::paintEvent(QPaintEvent * /* event */) { QPainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); option.backgroundColor = palette().color(QPalette::Background); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this); }
QStyle gets all the information it needs to render the graphical element from QStyleOption. The widget is passed as the last argument in case the style needs it to perform special effects (such as animated default buttons on Mac OS X), but it isn't mandatory. In fact, you can use QStyle to draw on any paint device, not just widgets, by setting the QPainter properly.
QStyleOption has various subclasses for the various types of graphical elements that can be drawn. For example, PE_FrameFocusRect expects a QStyleOptionFocusRect argument. This is documented for each enum value.
To ensure that drawing operations are as fast as possible, QStyleOption and its subclasses have public data members. See the QStyleOption class documentation for details on how to use it.
For convenience, Qt provides the QStylePainter class, which combines a QStyle, a QPainter, and a QWidget. This makes it possible to write
QStylePainter painter(this); ... painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
instead of
QPainter painter(this); ... style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
If you want to design a custom look and feel for your application, the first step is to pick one of the base styles provided with Qt to build your custom style from. The choice will depend on which existing style resembles your style the most.
Depending on which parts of the base style you want to change, you must reimplement the functions that are used to draw those parts of the interface. To illustrate this, we will modify the look of the spin box arrows drawn by QWindowsStyle. The arrows are primitive elements that are drawn by the drawPrimitive() function, so we need to reimplement that function. We need the following class declaration:
class CustomStyle : public QWindowsStyle { Q_OBJECT public: CustomStyle() {} ~CustomStyle() {} void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const; };
The PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements are used by QSpinBox to draw its up and down arrows. Here's how to reimplement drawPrimitive() to draw them differently:
void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (element == PE_IndicatorSpinUp || element == PE_IndicatorSpinDown) { QPointArray points(3); int x = option->rect.x(); int y = option->rect.y(); int w = option->rect.width() / 2; int h = option->rect.height() / 2; x += (option->rect.width() - w) / 2; y += (option->rect.height() - h) / 2; if (element == PE_IndicatorSpinUp) { points[0] = QPoint(x, y + h); points[1] = QPoint(x + w, y + h); points[2] = QPoint(x + w / 2, y); } else { // PE_SpinBoxDown points[0] = QPoint(x, y); points[1] = QPoint(x + w, y); points[2] = QPoint(x + w / 2, y + h); } if (option->state & Style_Enabled) { painter->setPen(option->palette.mid().color()); painter->setBrush(option->palette.buttonText()); } else { painter->setPen(option->palette.buttonText().color()); painter->setBrush(option->palette.mid()); } painter->drawPolygon(points); } else { QWindowsStyle::drawPrimitive(element, option, painter, widget); } }
Notice that we don't use the widget argument, except to pass it on to QWindowStyle::drawPrimitive(). As mentioned earlier, the information about what is to be drawn and how it should be drawn is specified by a QStyleOption object, so there is no need to ask the widget.
If you need to use the widget argument to obtain additional information, be careful to ensure that it isn't 0 and that it is of the correct type before using it. For example:
QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget); if (spinBox) { ... }
When implementing a custom style, you cannot assume that the widget is a QSpinBox just because the enum value is called PE_IndicatorSpinUp or PE_IndicatorSpinUp.
The documentation for the Styles example covers this topic in more detail.
There are several ways of using a custom style in a Qt application. The simplest way is call the QApplication::setStyle() static function before creating the QApplication object:
#include <QtGui> #include "customstyle.h" int main(int argc, char *argv[]) { QApplication::setStyle(new CustomStyle); QApplication app(argc, argv); QSpinBox spinBox; spinBox.show(); return app.exec(); }
You can call QApplication::setStyle() at any time, but by calling it before the constructor, you ensure that the user's preference, set using the -style command-line option, is respected.
You may want to make your style available for use in other applications, some of which may not be yours and are not available for you to recompile. The Qt Plugin system makes it possible to create styles as plugins. Styles created as plugins are loaded as shared objects at runtime by Qt itself. Please refer to the Qt Plugin documentation for more information on how to go about creating a style plugin.
Compile your plugin and put it into $QTDIR/plugins/styles. We now have a pluggable style that Qt can load automatically. To use your new style with existing applications, simply start the application with the following argument:
./myapplication -style custom
The application will use the look and feel from the custom style you implemented.
Languages written from right to left (such as Arabic and Hebrew) usually also mirror the whole layout of widgets, and require the light to come from the screen's top-right corner instead of top-left.
If you create a custom style, you should take special care when drawing asymmetric elements to make sure that they also look correct in a mirrored layout. An easy way to test your styles is to run applications with the -reverse command-line option or to call QApplication::setLayoutDirection() in your main() function.
Here are some things to keep in mind when making a style work well in a right-to-left environment:
See also QStyleOption and QStylePainter.
This enum represents a ComplexControl. ComplexControls have different behavior depending upon where the user clicks on them or which keys are pressed.
Constant | Value | Description |
---|---|---|
QStyle::CC_SpinBox | 0 | A spinbox, like QSpinBox |
QStyle::CC_ComboBox | 1 | A combobox, like QComboBox |
QStyle::CC_ScrollBar | 2 | A scroll bar, like QScrollBar |
QStyle::CC_Slider | 3 | A slider, like QSlider |
QStyle::CC_ToolButton | 4 | A tool button, like QToolButton |
QStyle::CC_TitleBar | 5 | A Title bar, like what is used in Q3Workspace |
QStyle::CC_Q3ListView | 6 | Used for drawing the Q3ListView class |
QStyle::CC_GroupBox | 8 | A group box, like QGroupBox |
QStyle::CC_Dial | 7 | A dial, like QDial |
QStyle::CC_CustomBase | 0xf0000000 | Base value for custom ControlElements. Custom values must be greater than this value. |
See also SubControl and drawComplexControl().
This enum represents a ContentsType. It is used to calculate sizes for the contents of various widgets.
Constant | Value | Description |
---|---|---|
QStyle::CT_CheckBox | 1 | A check box, like QCheckBox |
QStyle::CT_ComboBox | 4 | A combo box, like QComboBox |
QStyle::CT_DialogButtons | 20 | |
QStyle::CT_Q3DockWindow | 6 | |
QStyle::CT_HeaderSection | 21 | A header section, like QHeader |
QStyle::CT_LineEdit | 16 | A line edit, like QLineEdit |
QStyle::CT_Menu | 11 | A menu, like QMenu |
QStyle::CT_Q3Header | 15 | A Qt 3 header section, like Q3Header |
QStyle::CT_MenuBar | 10 | A menu bar, like QMenuBar |
QStyle::CT_MenuBarItem | 9 | A menu bar item, like the buttons in a QMenuBar |
QStyle::CT_MenuItem | 8 | A menu item, like QMenuItem |
QStyle::CT_ProgressBar | 7 | A progress bar, like QProgressBar |
QStyle::CT_PushButton | 0 | A push button, like QPushButton |
QStyle::CT_RadioButton | 2 | A radio button, like QRadioButton |
QStyle::CT_SizeGrip | 18 | A size grip, like QSizeGrip |
QStyle::CT_Slider | 13 | A slider, like QSlider |
QStyle::CT_ScrollBar | 14 | A scroll bar, like QScrollBar |
QStyle::CT_SpinBox | 17 | A spin box, like QSpinBox |
QStyle::CT_Splitter | 5 | A splitter, like QSplitter |
QStyle::CT_TabBarTab | 12 | A tab on a tab bar, like QTabBar |
QStyle::CT_TabWidget | 19 | A tab widget, like QTabWidget |
QStyle::CT_ToolButton | 3 | A tool button, like QToolButton |
QStyle::CT_GroupBox | 22 | A group box, like QGroupBox |
QStyle::CT_CustomBase | 0xf0000000 | Base value for custom ControlElements. Custom values must be greater than this value. |
See also sizeFromContents().
This enum represents a ControlElement. A ControlElement is part of a widget that performs some action or displays information to the user.
Constant | Value | Description |
---|---|---|
QStyle::CE_PushButton | 0 | A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect |
QStyle::CE_PushButtonBevel | 1 | The bevel and default indicator of a QPushButton. |
QStyle::CE_PushButtonLabel | 2 | The label (icon with text or pixmap) of a QPushButton |
QStyle::CE_DockWidgetTitle | 31 | Dock window title. |
QStyle::CE_Splitter | 29 | Splitter handle; see also QSplitter. |
QStyle::CE_CheckBox | 3 | A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect |
QStyle::CE_CheckBoxLabel | 4 | The label (text or pixmap) of a QCheckBox |
QStyle::CE_RadioButton | 5 | A QRadioButton, draws a PE_ExclusiveRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect |
QStyle::CE_RadioButtonLabel | 6 | The label (text or pixmap) of a QRadioButton |
QStyle::CE_TabBarTab | 7 | The tab and label within a QTabBar |
QStyle::CE_TabBarTabShape | 8 | The tab shape within a tab bar |
QStyle::CE_TabBarTabLabel | 9 | The label within a tab |
QStyle::CE_ProgressBar | 10 | A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel |
QStyle::CE_ProgressBarGroove | 11 | The groove where the progress indicator is drawn in a QProgressBar |
QStyle::CE_ProgressBarContents | 12 | The progress indicator of a QProgressBar |
QStyle::CE_ProgressBarLabel | 13 | The text label of a QProgressBar |
QStyle::CE_ToolButtonLabel | 22 | A tool button's label |
QStyle::CE_MenuBarItem | 20 | A menu item in a QMenuBar |
QStyle::CE_MenuBarEmptyArea | 21 | The empty area of a QMenuBar |
QStyle::CE_MenuItem | 14 | A menu item in a QMenu |
QStyle::CE_MenuScroller | 15 | Scrolling areas in a QMenu when the style supports scrolling |
QStyle::CE_MenuTearoff | 18 | A menu item representing the tear off section of a QMenu |
QStyle::CE_MenuEmptyArea | 19 | The area in a menu without menu items |
QStyle::CE_MenuHMargin | 17 | The horizontal extra space on the left/right of a menu |
QStyle::CE_MenuVMargin | 16 | The vertical extra space on the top/bottom of a menu |
QStyle::CE_Q3DockWindowEmptyArea | 26 | The empty area of a QDockWidget |
QStyle::CE_ToolBoxTab | 27 | The toolbox's tab area |
QStyle::CE_SizeGrip | 28 | Window resize handle; see also QSizeGrip. |
QStyle::CE_Header | 23 | A header |
QStyle::CE_HeaderSection | 24 | A header section |
QStyle::CE_HeaderLabel | 25 | The header's label |
QStyle::CE_ScrollBarAddLine | 32 | Scroll bar line increase indicator. (i.e., scroll down); see also QScrollBar. |
QStyle::CE_ScrollBarSubLine | 33 | Scroll bar line decrease indicator (i.e., scroll up). |
QStyle::CE_ScrollBarAddPage | 34 | Scolllbar page increase indicator (i.e., page down). |
QStyle::CE_ScrollBarSubPage | 35 | Scroll bar page decrease indicator (i.e., page up). |
QStyle::CE_ScrollBarSlider | 36 | Scroll bar slider. |
QStyle::CE_ScrollBarFirst | 37 | Scroll bar first line indicator (i.e., home). |
QStyle::CE_ScrollBarLast | 38 | Scroll bar last line indicator (i.e., end). |
QStyle::CE_RubberBand | 30 | Rubber band used in such things as iconview. |
QStyle::CE_FocusFrame | 39 | Focus Frame that can is style controled. |
QStyle::CE_CustomBase | 0xf0000000 | Base value for custom ControlElements; custom values must be greater than this value |
QStyle::CE_ComboBoxLabel | 40 | The label of a non-editable QComboBox |
QStyle::CE_ToolBar | 41 | A toolbar like QToolBar |
See also drawControl().
This enum represents a PixelMetric. A PixelMetric is a style dependent size represented as a single pixel value.
Constant | Value | Description |
---|---|---|
QStyle::PM_ButtonMargin | 0 | Amount of whitespace between push button labels and the frame |
QStyle::PM_ButtonDefaultIndicator | 1 | Width of the default-button indicator frame |
QStyle::PM_MenuButtonIndicator | 2 | Width of the menu button indicator proportional to the widget height |
QStyle::PM_ButtonShiftHorizontal | 3 | Horizontal contents shift of a button when the button is down |
QStyle::PM_ButtonShiftVertical | 4 | Vertical contents shift of a button when the button is down |
QStyle::PM_DefaultFrameWidth | 5 | Default frame width (usually 2) |
QStyle::PM_SpinBoxFrameWidth | 6 | Frame width of a spin box, defaults to PM_DefaultFrameWidth |
QStyle::PM_ComboBoxFrameWidth | 7 | Frame width of a combo box, defaults to PM_DefaultFrameWidth. |
QStyle::PM_MDIFrameWidth | 46 | Frame width of an MDI window |
QStyle::PM_MDIMinimizedWidth | 47 | Width of a minimized MDI window |
QStyle::PM_MaximumDragDistance | 8 | Some feels require the scroll bar or other sliders to jump back to the original position when the mouse pointer is too far away while dragging; a value of -1 disables this behavior |
QStyle::PM_ScrollBarExtent | 9 | Width of a vertical scroll bar and the height of a horizontal scroll bar |
QStyle::PM_ScrollBarSliderMin | 10 | The minimum height of a vertical scroll bar's slider and the minimum width of a horizontal scroll bar's slider |
QStyle::PM_SliderThickness | 11 | Total slider thickness |
QStyle::PM_SliderControlThickness | 12 | Thickness of the slider handle |
QStyle::PM_SliderLength | 13 | Length of the slider |
QStyle::PM_SliderTickmarkOffset | 14 | The offset between the tickmarks and the slider |
QStyle::PM_SliderSpaceAvailable | 15 | The available space for the slider to move |
QStyle::PM_DockWidgetSeparatorExtent | 16 | Width of a separator in a horizontal dock window and the height of a separator in a vertical dock window |
QStyle::PM_DockWidgetHandleExtent | 17 | Width of the handle in a horizontal dock window and the height of the handle in a vertical dock window |
QStyle::PM_DockWidgetFrameWidth | 18 | Frame width of a dock window |
QStyle::PM_DockWidgetTitleMargin | 75 | Margin of the dock window title |
QStyle::PM_MenuBarPanelWidth | 33 | Frame width of a menubar, defaults to PM_DefaultFrameWidth |
QStyle::PM_MenuBarItemSpacing | 34 | Spacing between menubar items |
QStyle::PM_MenuBarHMargin | 36 | Spacing between menubar items and left/right of bar |
QStyle::PM_MenuBarVMargin | 35 | Spacing between menubar items and top/bottom of bar |
QStyle::PM_ToolBarFrameWidth | 54 | Width of the frame around toolbars |
QStyle::PM_ToolBarHandleExtent | 55 | Width of a toolbar handle in a horizontal toolbar and the height of the handle in a vertical toolbar |
QStyle::PM_ToolBarItemMargin | 57 | Spacing between the toolbar frame and the items |
QStyle::PM_ToolBarItemSpacing | 56 | Spacing between toolbar items |
QStyle::PM_ToolBarSeparatorExtent | 58 | Width of a toolbar separator in a horizontal toolbar and the height of a separator in a vertical toolbar |
QStyle::PM_ToolBarExtensionExtent | 59 | Width of a toolbar extension button in a horizontal toolbar and the height of the button in a vertical toolbar |
QStyle::PM_TabBarTabOverlap | 19 | Number of pixels the tabs should overlap |
QStyle::PM_TabBarTabHSpace | 20 | Extra space added to the tab width |
QStyle::PM_TabBarTabVSpace | 21 | Extra space added to the tab height |
QStyle::PM_TabBarBaseHeight | 22 | Height of the area between the tab bar and the tab pages |
QStyle::PM_TabBarBaseOverlap | 23 | Number of pixels the tab bar overlaps the tab bar base |
QStyle::PM_TabBarScrollButtonWidth | 53 | |
QStyle::PM_TabBarTabShiftHorizontal | 51 | Horizontal pixel shift when a tab is selected |
QStyle::PM_TabBarTabShiftVertical | 52 | Vertical pixel shift when a tab is selected |
QStyle::PM_ProgressBarChunkWidth | 24 | Width of a chunk in a progress bar indicator |
QStyle::PM_SplitterWidth | 25 | Width of a splitter |
QStyle::PM_TitleBarHeight | 26 | Height of the title bar |
QStyle::PM_IndicatorWidth | 37 | Width of a check box indicator |
QStyle::PM_IndicatorHeight | 38 | Height of a checkbox indicator |
QStyle::PM_ExclusiveIndicatorWidth | 39 | Width of a radio button indicator |
QStyle::PM_ExclusiveIndicatorHeight | 40 | Height of a radio button indicator |
QStyle::PM_MenuPanelWidth | 30 | Border width (applied on all sides) for a QMenu |
QStyle::PM_MenuHMargin | 28 | Additional border (used on left and right) for a QMenu |
QStyle::PM_MenuVMargin | 29 | Additional border (used for bottom and top) for a QMenu |
QStyle::PM_MenuScrollerHeight | 27 | Height of the scroller area in a QMenu |
QStyle::PM_MenuScrollerHeight | 27 | Height of the scroller area in a QMenu |
QStyle::PM_MenuTearoffHeight | 31 | Height of a tear off area in a QMenu |
QStyle::PM_MenuDesktopFrameWidth | 32 | |
QStyle::PM_CheckListButtonSize | 41 | Area (width/height) of the checkbox/radio button in a Q3CheckListItem |
QStyle::PM_CheckListControllerSize | 42 | Area (width/height) of the controller in a Q3CheckListItem |
QStyle::PM_DialogButtonsSeparator | 43 | Distance between buttons in a dialog buttons widget |
QStyle::PM_DialogButtonsButtonWidth | 44 | Minimum width of a button in a dialog buttons widget |
QStyle::PM_DialogButtonsButtonHeight | 45 | Minimum height of a button in a dialog buttons widget |
QStyle::PM_HeaderMarkSize | 49 | |
QStyle::PM_HeaderGripMargin | 50 | |
QStyle::PM_HeaderMargin | 48 | |
QStyle::PM_SpinBoxSliderHeight | 60 | The height of the optional spin box slider |
QStyle::PM_DefaultTopLevelMargin | 61 | |
QStyle::PM_DefaultChildMargin | 62 | |
QStyle::PM_DefaultLayoutSpacing | 63 | |
QStyle::PM_ToolBarIconSize | 64 | Default tool bar icon size |
QStyle::PM_SmallIconSize | 67 | Default small icon size |
QStyle::PM_LargeIconSize | 68 | Default large icon size |
QStyle::PM_FocusFrameHMargin | 70 | Horizontal margin that the focus frame will outset the widget by. |
QStyle::PM_FocusFrameVMargin | 69 | Vertical margin that the focus frame will outset the widget by. |
QStyle::PM_IconViewIconSize | 66 | |
QStyle::PM_ListViewIconSize | 65 | |
QStyle::PM_ToolTipLabelFrameWidth | 71 | |
QStyle::PM_CheckBoxLabelSpacing | 72 | The spacing between a check box and its label |
QStyle::PM_TabBarIconSize | 73 | The default icon size for a tab bar. |
QStyle::PM_SizeGripSize | 74 | The size of a size grip |
QStyle::PM_CustomBase | 0xf0000000 | Base value for custom ControlElements Custom values must be greater than this value |
See also pixelMetric().
This enum represents a style's PrimitiveElements. A PrimitiveElement is a common GUI element, such as a checkbox indicator or button bevel.
Constant | Value | Description |
---|---|---|
QStyle::PE_PanelButtonCommand | 18 | Button used to initiate an action, for example, a QPushButton. |
QStyle::PE_FrameDefaultButton | 6 | This frame around a default button, e.g. in a dialog. |
QStyle::PE_PanelButtonBevel | 19 | Generic panel with a button bevel. |
QStyle::PE_PanelButtonTool | 20 | Panel for a Tool button, used with QToolButton. |
QStyle::PE_PanelLineEdit | 23 | Panel for a QLineEdit. |
QStyle::PE_IndicatorButtonDropDown | 29 | indicator for a drop down button, for example, a tool button that displays a menu. |
QStyle::PE_FrameFocusRect | 8 | Generic focus indicator. |
QStyle::PE_IndicatorArrowUp | 27 | Generic Up arrow. |
QStyle::PE_IndicatorArrowDown | 24 | Generic Down arrow. |
QStyle::PE_IndicatorArrowRight | 26 | Generic Right arrow. |
QStyle::PE_IndicatorArrowLeft | 25 | Generic Left arrow. |
QStyle::PE_IndicatorSpinUp | 40 | Up symbol for a spin widget, for example a QSpinBox. |
QStyle::PE_IndicatorSpinDown | 37 | Down symbol for a spin widget. |
QStyle::PE_IndicatorSpinPlus | 39 | Increase symbol for a spin widget. |
QStyle::PE_IndicatorSpinMinus | 38 | Decrease symbol for a spin widget. |
QStyle::PE_IndicatorViewItemCheck | 30 | On/off indicator for a view item |
QStyle::PE_IndicatorCheckBox | 31 | On/off indicator, for example, a QCheckBox. |
QStyle::PE_IndicatorRadioButton | 36 | Exclusive on/off indicator, for example, a QRadioButton. |
QStyle::PE_Q3DockWindowSeparator | 3 | Item separator for Qt 3 compatible dock window and toolbar contents. |
QStyle::PE_IndicatorDockWidgetResizeHandle | 32 | Resize handle for dock windows. |
QStyle::PE_Frame | 5 | Generic frame; see also QFrame. |
QStyle::PE_FrameMenu | 11 | Frame for popup windows/menus; see also QMenu. |
QStyle::PE_PanelMenuBar | 21 | Panel for menu bars. |
QStyle::PE_FrameDockWidget | 7 | Panel frame for dock windows and toolbars. |
QStyle::PE_FrameTabWidget | 13 | Frame for tab widgets. |
QStyle::PE_FrameLineEdit | 10 | Panel frame for line edits. |
QStyle::PE_FrameGroupBox | 9 | Panel frame around group boxes. |
QStyle::PE_FrameButtonBevel | 15 | Panel frame for a button bevel |
QStyle::PE_FrameButtonTool | 16 | Panel frame for a tool button |
QStyle::PE_IndicatorHeaderArrow | 33 | Arrow used to indicate sorting on a list or table header |
QStyle::PE_FrameStatusBar | 12 | Frame for a section of a status bar; see also QStatusBar. |
QStyle::PE_FrameWindow | 14 | Frame around a MDI window or a docking window. |
QStyle::PE_Q3Separator | 4 | Qt 3 compatible generic separator. |
QStyle::PE_IndicatorMenuCheckMark | 34 | Check mark used in a menu. |
QStyle::PE_IndicatorProgressChunk | 35 | Section of a progress bar indicator; see also QProgressBar. |
QStyle::PE_Q3CheckListController | 0 | Qt 3 compatible Controller part of a list view item. |
QStyle::PE_Q3CheckListIndicator | 2 | Qt 3 compatible Checkbox part of a list view item. |
QStyle::PE_Q3CheckListExclusiveIndicator | 1 | Qt 3 compatible Radio button part of a list view item. |
QStyle::PE_IndicatorBranch | 28 | Lines used to represent the branch of a tree in a tree view. |
QStyle::PE_IndicatorToolBarHandle | 41 | The handle of a toolbar. |
QStyle::PE_IndicatorToolBarSeparator | 42 | The separator in a toolbar. |
QStyle::PE_PanelToolBar | 22 | The panel for a toolbar. |
QStyle::PE_PanelTipLabel | 43 | The panel for a tip label. |
QStyle::PE_FrameTabBarBase | 17 | The frame that is drawn for a tabbar, ususally drawn for a tabbar that isn't part of a tab widget |
QStyle::PE_IndicatorTabTear | 44 | An indicator that a tab is partially scrolled out of the visible tab bar when there are many tabs. |
QStyle::PE_CustomBase | 0xf000000 | Base value for custom PrimitiveElements. All values above this are reserved for custom use. Custom values must be greater than this value. |
See also drawPrimitive().
This enum represents a StandardPixmap. A StandardPixmap is a pixmap that can follow some existing GUI style or guideline.
Constant | Value | Description |
---|---|---|
QStyle::SP_TitleBarMinButton | 1 | Minimize button on title bars (e.g., in QWorkspace) |
QStyle::SP_TitleBarMenuButton | 0 | Menu button on a title bar |
QStyle::SP_TitleBarMaxButton | 2 | Maximize button on title bars |
QStyle::SP_TitleBarCloseButton | 3 | Close button on title bars |
QStyle::SP_TitleBarNormalButton | 4 | Normal (restore) button on title bars |
QStyle::SP_TitleBarShadeButton | 5 | Shade button on title bars |
QStyle::SP_TitleBarUnshadeButton | 6 | Unshade button on title bars |
QStyle::SP_TitleBarContextHelpButton | 7 | The Context help button on title bars |
QStyle::SP_MessageBoxInformation | 9 | The "information" icon |
QStyle::SP_MessageBoxWarning | 10 | The "warning" icon |
QStyle::SP_MessageBoxCritical | 11 | The "critical" icon |
QStyle::SP_MessageBoxQuestion | 12 | The "question" icon |
QStyle::SP_DesktopIcon | 13 | |
QStyle::SP_TrashIcon | 14 | |
QStyle::SP_ComputerIcon | 15 | |
QStyle::SP_DriveFDIcon | 16 | |
QStyle::SP_DriveHDIcon | 17 | |
QStyle::SP_DriveCDIcon | 18 | |
QStyle::SP_DriveDVDIcon | 19 | |
QStyle::SP_DriveNetIcon | 20 | |
QStyle::SP_DirOpenIcon | 21 | |
QStyle::SP_DirClosedIcon | 22 | |
QStyle::SP_DirLinkIcon | 23 | |
QStyle::SP_FileIcon | 24 | |
QStyle::SP_FileLinkIcon | 25 | |
QStyle::SP_FileDialogStart | 28 | |
QStyle::SP_FileDialogEnd | 29 | |
QStyle::SP_FileDialogToParent | 30 | |
QStyle::SP_FileDialogNewFolder | 31 | |
QStyle::SP_FileDialogDetailedView | 32 | |
QStyle::SP_FileDialogInfoView | 33 | |
QStyle::SP_FileDialogContentsView | 34 | |
QStyle::SP_FileDialogListView | 35 | |
QStyle::SP_FileDialogBack | 36 | |
QStyle::SP_DockWidgetCloseButton | 8 | Close button on dock windows (see also QDockWidget) |
QStyle::SP_ToolBarHorizontalExtensionButton | 26 | Extension button for horizontal toolbars |
QStyle::SP_ToolBarVerticalExtensionButton | 27 | Extension button for vertical toolbars |
QStyle::SP_CustomBase | 0xf0000000 | Base value for custom ControlElements; custom values must be greater than this value |
See also standardPixmap().
This enum represents flags for drawing PrimitiveElements. Not all primitives use all of these flags. Note that these flags may mean different things to different primitives.
Constant | Value |
---|---|
QStyle::State_Active | 0x00010000 |
QStyle::State_AutoRaise | 0x00001000 |
QStyle::State_Bottom | 0x00000400 |
QStyle::State_Children | 0x00080000 |
QStyle::State_None | 0x00000000 |
QStyle::State_DownArrow | 0x00000040 |
QStyle::State_Editing | 0x00400000 |
QStyle::State_Enabled | 0x00000001 |
QStyle::State_FocusAtBorder | 0x00000800 |
QStyle::State_HasFocus | 0x00000100 |
QStyle::State_HasFocus | 0x00000100 |
QStyle::State_Horizontal | 0x00000080 |
QStyle::State_Item | 0x00100000 |
QStyle::State_MouseOver | 0x00002000 |
QStyle::State_NoChange | 0x00000010 |
QStyle::State_Off | 0x00000008 |
QStyle::State_On | 0x00000020 |
QStyle::State_Open | 0x00040000 |
QStyle::State_Raised | 0x00000002 |
QStyle::State_Selected | 0x00008000 |
QStyle::State_Sibling | 0x00200000 |
QStyle::State_Sunken | 0x00000004 |
QStyle::State_Top | 0x00000200 |
QStyle::State_UpArrow | 0x00004000 |
QStyle::State_KeyboardFocusChange | 0x00800000 |
QStyle::State_ReadOnly | 0x02000000 |
The State type is a typedef for QFlags<StateFlag>. It stores an OR combination of StateFlag values.
See also drawPrimitive().
This enum represents a StyleHint. A StyleHint is a general look and/or feel hint.
Constant | Value | Description |
---|---|---|
QStyle::SH_EtchDisabledText | 0 | Disabled text is "etched" as it is on Windows. |
QStyle::SH_DitherDisabledText | 1 | |
QStyle::SH_GUIStyle | 0x00000100 | The GUI style to use. |
QStyle::SH_ScrollBar_MiddleClickAbsolutePosition | 2 | A boolean value. If true, middle clicking on a scroll bar causes the slider to jump to that position. If false, middle clicking is ignored. |
QStyle::SH_ScrollBar_LeftClickAbsolutePosition | 39 | A boolean value. If true, left clicking on a scroll bar causes the slider to jump to that position. If false, left clicking will behave as appropriate for each control. |
QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl | 3 | A boolean value. If true, when clicking a scroll bar SubControl, holding the mouse button down and moving the pointer outside the SubControl, the scroll bar continues to scroll. If false, the scollbar stops scrolling when the pointer leaves the SubControl. |
QStyle::SH_ScrollBar_RollBetweenButtons | 64 | A boolean value. If true, when clicking a scrollbar button (SC_ScrollBarAddLine or SC_ScrollBarSubLine) and dragging over to the opposite button (rolling) will press the new button and release the old one. When it is false, the original button is released and nothing happens (like a pushbutton). |
QStyle::SH_TabBar_Alignment | 5 | The alignment for tabs in a QTabWidget. Possible values are Qt::AlignLeft, Qt::AlignCenter and Qt::AlignRight. |
QStyle::SH_Header_ArrowAlignment | 6 | The placement of the sorting indicator may appear in list or table headers. Possible values are Qt::Left or Qt::Right. |
QStyle::SH_Slider_SnapToValue | 7 | Sliders snap to values while moving, as they do on Windows. |
QStyle::SH_Slider_SloppyKeyEvents | 8 | Key presses handled in a sloppy manner, i.e., left on a vertical slider subtracts a line. |
QStyle::SH_ProgressDialog_CenterCancelButton | 9 | Center button on progress dialogs, like Motif, otherwise right aligned. |
QStyle::SH_ProgressDialog_TextLabelAlignment | 10 | Type Qt::Alignment. Text label alignment in progress dialogs; Qt::Center on windows, Qt::VCenter otherwise. |
QStyle::SH_PrintDialog_RightAlignButtons | 11 | Right align buttons in the print dialog, as done on Windows. |
QStyle::SH_MainWindow_SpaceBelowMenuBar | 12 | One or two pixel space between the menubar and the dockarea, as done on Windows. |
QStyle::SH_FontDialog_SelectAssociatedText | 13 | Select the text in the line edit, or when selecting an item from the listbox, or when the line edit receives focus, as done on Windows. |
QStyle::SH_Menu_AllowActiveAndDisabled | 14 | Allows disabled menu items to be active. |
QStyle::SH_Menu_SpaceActivatesItem | 15 | Pressing the space bar activates the item, as done on Motif. |
QStyle::SH_Menu_SubMenuPopupDelay | 16 | The number of milliseconds to wait before opening a submenu (256 on windows, 96 on Motif). |
QStyle::SH_Menu_Scrollable | 30 | Whether popup menus must support scrolling. |
QStyle::SH_Menu_SloppySubMenus | 33 | Whether popupmenu's must support sloppy submenu; as implemented on Mac OS. |
QStyle::SH_ScrollView_FrameOnlyAroundContents | 17 | Whether scrollviews draw their frame only around contents (like Motif), or around contents, scroll bars and corner widgets (like Windows). |
QStyle::SH_MenuBar_AltKeyNavigation | 18 | Menu bars items are navigable by pressing Alt, followed by using the arrow keys to select the desired item. |
QStyle::SH_ComboBox_ListMouseTracking | 19 | Mouse tracking in combobox drop-down lists. |
QStyle::SH_Menu_MouseTracking | 20 | Mouse tracking in popup menus. |
QStyle::SH_MenuBar_MouseTracking | 21 | Mouse tracking in menubars. |
QStyle::SH_Menu_FillScreenWithScroll | 45 | Whether scrolling popups should fill the screen as they are scrolled. |
QStyle::SH_ItemView_ChangeHighlightOnFocus | 22 | Gray out selected items when losing focus. |
QStyle::SH_Widget_ShareActivation | 23 | Turn on sharing activation with floating modeless dialogs. |
QStyle::SH_TabBar_SelectMouseType | 4 | Which type of mouse event should cause a tab to be selected. |
QStyle::SH_Q3ListViewExpand_SelectMouseType | 40 | Which type of mouse event should cause a list view expansion to be selected. |
QStyle::SH_TabBar_PreferNoArrows | 38 | Whether a tabbar should suggest a size to prevent scoll arrows. |
QStyle::SH_ComboBox_Popup | 25 | Allows popups as a combobox drop-down menu. |
QStyle::SH_Workspace_FillSpaceOnMaximize | 24 | The workspace should maximize the client area. |
QStyle::SH_TitleBar_NoBorder | 26 | The title bar has no border. |
QStyle::SH_ScrollBar_StopMouseOverSlider | 27 | Stops auto-repeat when the slider reaches the mouse position. |
QStyle::SH_BlinkCursorWhenTextSelected | 28 | Whether cursor should blink when text is selected. |
QStyle::SH_RichText_FullWidthSelection | 29 | Whether richtext selections should extend to the full width of the document. |
QStyle::SH_GroupBox_TextLabelVerticalAlignment | 31 | How to vertically align a groupbox's text label. |
QStyle::SH_GroupBox_TextLabelColor | 32 | How to paint a groupbox's text label. |
QStyle::SH_DialogButtons_DefaultButton | 36 | Which button gets the default status in a dialog's button widget. |
QStyle::SH_ToolBox_SelectedPageTitleBold | 37 | Boldness of the selected page title in a QToolBox. |
QStyle::SH_LineEdit_PasswordCharacter | 35 | The Unicode character to be used for passwords. |
QStyle::SH_Table_GridLineColor | 34 | |
QStyle::SH_UnderlineShortcut | 41 | Whether shortcuts are underlined. |
QStyle::SH_SpinBox_AnimateButton | 42 | Animate a click when up or down is pressed in a spin box. |
QStyle::SH_SpinBox_KeyPressAutoRepeatRate | 43 | Auto-repeat interval for spinbox key presses. |
QStyle::SH_SpinBox_ClickAutoRepeatRate | 44 | Auto-repeat interval for spinbox mouse clicks. |
QStyle::SH_ToolTipLabel_Opacity | 46 | An integer indicating the opacity for the tip label, 0 is completely transparent, 255 is completely opaque. |
QStyle::SH_DrawMenuBarSeparator | 47 | Indicates whether or not the menubar draws separators. |
QStyle::SH_TitleBar_ModifyNotification | 48 | Indicates if the titlebar should show a '*' for windows that are modified. |
QStyle::SH_Button_FocusPolicy | 49 | The default focus policy for buttons. |
QStyle::SH_CustomBase | 0xf0000000 | Base value for custom ControlElements. Custom values must be greater than this value. |
QStyle::SH_MenuBar_DismissOnSecondClick | 50 | A boolean indicating if a menu in the menubar should be dismissed when it is clicked on a second time. (Example: Clicking and releasing on the File Menu in a menubar and then immediately clicking on the File Menu again.) |
QStyle::SH_MessageBox_UseBorderForButtonSpacing | 51 | A boolean indicating what the to use the border of the buttons (computed as half the button height) for the spacing of the button in a message box. |
QStyle::SH_TitleBar_AutoRaise | 52 | A boolean indicating whether controls on a title bar ought to update when the mouse is over them. |
QStyle::SH_ToolButton_PopupDelay | 53 | An int indicating the popup delay in milliseconds for menus attached to tool buttons. |
QStyle::SH_FocusFrame_Mask | 54 | The mask of the focus frame. |
QStyle::SH_RubberBand_Mask | 55 | The mask of the rubber band. |
QStyle::SH_WindowFrame_Mask | 56 | The mask of the window frame. |
QStyle::SH_SpinControls_DisableOnBounds | 57 | Determines if the spin controls will shown as disabled when reaching the spin range boundary. |
QStyle::SH_Dial_BackgroundRole | 58 | Defines the style's preferred background role (as QPalette::ColorRole) for a dial widget. |
QStyle::SH_ScrollBar_BackgroundMode | The backgroundMode() for a scroll bar. | |
QStyle::SH_ComboBox_LayoutDirection | 59 | The layout direction for the combo box. By default it should be the same value as the QStyleOption's direction. |
QStyle::SH_ItemView_EllipsisLocation | 60 | The location where ellipses should be added for item text that is too long to fit in an view item. |
QStyle::SH_ItemView_ShowDecorationSelected | 61 | When an item in an item view is selected, also highlight the branch or other decoration. |
QStyle::SH_ItemView_ActivateItemOnSingleClick | 62 | Emit the activated signal when the user single clicks on an item in an item in an item view. Otherwise the signal is emitted when the user double clicks on an item. |
See also styleHint().
This enum represents a SubControl within a ComplexControl.
Constant | Value | Description |
---|---|---|
QStyle::SC_None | 0x00000000 | Special value that matches no other SubControl. |
QStyle::SC_ScrollBarAddLine | 0x00000001 | Scroll bar add line (i.e., down/right arrow); see also QScrollBar |
QStyle::SC_ScrollBarSubLine | 0x00000002 | Scroll bar sub line (i.e., up/left arrow) |
QStyle::SC_ScrollBarAddPage | 0x00000004 | Scroll bar add page (i.e., page down) |
QStyle::SC_ScrollBarSubPage | 0x00000008 | Scroll bar sub page (i.e., page up) |
QStyle::SC_ScrollBarFirst | 0x00000010 | Scroll bar first line (i.e., home) |
QStyle::SC_ScrollBarLast | 0x00000020 | Scroll bar last line (i.e., end) |
QStyle::SC_ScrollBarSlider | 0x00000040 | Scroll bar slider handle |
QStyle::SC_ScrollBarGroove | 0x00000080 | Special sub-control which contains the area in which the slider handle may move |
QStyle::SC_SpinBoxUp | 0x00000001 | Spinwidget up/increase; see also QSpinBox |
QStyle::SC_SpinBoxDown | 0x00000002 | Spinwidget down/decrease |
QStyle::SC_SpinBoxFrame | 0x00000004 | Spinwidget frame |
QStyle::SC_SpinBoxEditField | 0x00000008 | Spinwidget edit field |
QStyle::SC_ComboBoxEditField | 0x00000002 | Combobox edit field; see also QComboBox |
QStyle::SC_ComboBoxArrow | 0x00000004 | Combobox arrow button |
QStyle::SC_ComboBoxFrame | 0x00000001 | Combobox frame |
QStyle::SC_ComboBoxListBoxPopup | 0x00000008 | The reference rect for the combobox popup Used to calculate the position of the popup. |
QStyle::SC_SliderGroove | 0x00000001 | Special sub-control which contains the area in which the slider handle may move |
QStyle::SC_SliderHandle | 0x00000002 | Slider handle |
QStyle::SC_SliderTickmarks | 0x00000004 | Slider tickmarks |
QStyle::SC_ToolButton | 0x00000001 | Tool button (see also QToolButton) |
QStyle::SC_ToolButtonMenu | 0x00000002 | Sub-control for opening a popup menu in a tool button; see also Q3PopupMenu |
QStyle::SC_TitleBarSysMenu | 0x00000001 | System menu button (i.e., restore, close, etc.) |
QStyle::SC_TitleBarMinButton | 0x00000002 | Minimize button |
QStyle::SC_TitleBarMaxButton | 0x00000004 | Maximize button |
QStyle::SC_TitleBarCloseButton | 0x00000008 | Close button |
QStyle::SC_TitleBarLabel | 0x00000100 | Window title label |
QStyle::SC_TitleBarNormalButton | 0x00000010 | Normal (restore) button |
QStyle::SC_TitleBarShadeButton | 0x00000020 | Shade button |
QStyle::SC_TitleBarUnshadeButton | 0x00000040 | Unshade button |
QStyle::SC_TitleBarContextHelpButton | 0x00000080 | Context Help button |
QStyle::SC_Q3ListView | 0x00000001 | The list view area |
QStyle::SC_Q3ListViewExpand | 0x00000004 | Expand item (i.e., show/hide child items) |
QStyle::SC_DialHandle | 0x00000002 | The handle of the dial (i.e. what you use to control the dial) |
QStyle::SC_DialGroove | 0x00000001 | The groove for the dial |
QStyle::SC_DialTickmarks | 0x00000004 | The tickmarks for the dial |
QStyle::SC_GroupBoxFrame | 0x00000008 | The frame of a group box |
QStyle::SC_GroupBoxLabel | 0x00000002 | The title of a group box |
QStyle::SC_GroupBoxCheckBox | 0x00000001 | The optional check box of a group box |
QStyle::SC_GroupBoxContents | 0x00000004 | The group box contents |
QStyle::SC_All | 0xffffffff | Special value that matches all SubControls |
The SubControls type is a typedef for QFlags<SubControl>. It stores an OR combination of SubControl values.
See also ComplexControl.
This enum represents a sub-area of a widget. Style implementations use these areas to draw the different parts of a widget.
Constant | Value | Description |
---|---|---|
QStyle::SE_PushButtonContents | 0 | Area containing the label (icon with text or pixmap) |
QStyle::SE_PushButtonFocusRect | 1 | Area for the focus rect (usually larger than the contents rect) |
QStyle::SE_CheckBoxIndicator | 2 | Area for the state indicator (e.g., check mark) |
QStyle::SE_CheckBoxContents | 3 | Area for the label (text or pixmap) |
QStyle::SE_CheckBoxFocusRect | 4 | Area for the focus indicator |
QStyle::SE_CheckBoxClickRect | 5 | Clickable area, defaults to SE_CheckBoxFocusRect |
QStyle::SE_RadioButtonIndicator | 6 | Area for the state indicator |
QStyle::SE_RadioButtonContents | 7 | Area for the label |
QStyle::SE_RadioButtonFocusRect | 8 | Area for the focus indicator |
QStyle::SE_RadioButtonClickRect | 9 | Clickable area, defaults to SE_RadioButtonFocusRect |
QStyle::SE_ComboBoxFocusRect | 10 | Area for the focus indicator |
QStyle::SE_SliderFocusRect | 11 | Area for the focus indicator |
QStyle::SE_Q3DockWindowHandleRect | 12 | Area for the tear-off handle |
QStyle::SE_ProgressBarGroove | 13 | Area for the groove |
QStyle::SE_ProgressBarContents | 14 | Area for the progress indicator |
QStyle::SE_ProgressBarLabel | 15 | Area for the text label |
QStyle::SE_DialogButtonAccept | 16 | Area for a dialog's accept button |
QStyle::SE_DialogButtonReject | 17 | Area for a dialog's reject button |
QStyle::SE_DialogButtonApply | 18 | Area for a dialog's apply button |
QStyle::SE_DialogButtonHelp | 19 | Area for a dialog's help button |
QStyle::SE_DialogButtonAll | 20 | Area for a dialog's all button |
QStyle::SE_DialogButtonRetry | 23 | Area for a dialog's retry button |
QStyle::SE_DialogButtonAbort | 21 | Area for a dialog's abort button |
QStyle::SE_DialogButtonIgnore | 22 | Area for a dialog's ignore button |
QStyle::SE_DialogButtonCustom | 24 | Area for a dialog's custom widget area (in the button row) |
QStyle::SE_HeaderArrow | 27 | |
QStyle::SE_HeaderLabel | 26 | |
QStyle::SE_TabWidgetLeftCorner | 31 | |
QStyle::SE_TabWidgetRightCorner | 32 | |
QStyle::SE_TabWidgetTabBar | 28 | |
QStyle::SE_TabWidgetTabContents | 30 | |
QStyle::SE_TabWidgetTabPane | 29 | |
QStyle::SE_ToolBoxTabContents | 25 | Area for a toolbox tab's icon and label |
QStyle::SE_ViewItemCheckIndicator | 33 | Area for a view item's check mark |
QStyle::SE_TabBarTearIndicator | 34 | Area for the tear indicator on a tab bar with scroll arrows. |
QStyle::SE_TreeViewDisclosureItem | 35 | Area for the actual disclosure item in a tree branch. |
QStyle::SE_CustomBase | 0xf0000000 | Base value for custom ControlElements Custom values must be greater than this value |
See also subElementRect().
Constructs a style object.
Destroys the style object.
Returns a new rectangle of size that is aligned to rectangle according to alignment and based on direction.
Draws the ComplexControl control using painter with the style options specified by option.
The widget argument is optional and may contain a widget to aid in drawing control.
The option parameter is a pointer to a QStyleOptionComplex structure that can be cast to the correct structure. Note that the rect member of option must be in logical coordinates. Reimplementations of this function should use visualRect() to change the logical coordinates into screen coordinates before calling drawPrimitive() or drawControl().
Here is a table listing the elements and what they can be cast to, along with an explaination of the flags.
ComplexControl | Option Cast | Style Flag | Remark |
---|---|---|---|
CC_SpinBox | QStyleOptionSpinBox | State_Enabled | Set if the spin box is enabled |
State_HasFocus | Set if the spin box has input focus | ||
CC_ComboBox | QStyleOptionComboBox | State_Enabled | Set if the combobox is enabled |
State_HasFocus | Set if the combobox has input focus | ||
CC_ScrollBar | QStyleOptionSlider | State_Enabled | Set if the scroll bar is enabled |
State_HasFocus | Set if the scroll bar has input focus | ||
CC_Slider | QStyleOptionSlider | State_Enabled | Set if the slider is enabled |
State_HasFocus | Set if the slider has input focus | ||
CC_Dial | QStyleOptionSlider | State_Enabled | Set if the dial is enabled |
State_HasFocus | Set if the dial has input focus | ||
CC_ToolButton | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled |
State_HasFocus | Set if the tool button has input focus | ||
State_DownArrow | Set if the tool button is down (i.e., a mouse button or the space bar is pressed) | ||
State_On | Set if the tool button is a toggle button and is toggled on | ||
State_AutoRaise | Set if the tool button has auto-raise enabled | ||
State_Raised | Set if the button is not down, not on, and doesn't contain the mouse when auto-raise is enabled | ||
CC_TitleBar | QStyleOptionTitleBar | State_Enabled | Set if the title bar is enabled |
CC_Q3ListView | QStyleOptionQ3ListView | State_Enabled | Set if the list view is enabled |
See also ComplexControl, SubControl, and QStyleOptionComplex.
Draws the ControlElement element with painter with the style options specified by option.
The widget argument is optional and may contain a widget that may aid in drawing the control.
What follows is a table of the elements and the QStyleOption structure the option parameter can cast to. The flags stored in the QStyleOption state variable are also listed. If a ControlElement is not listed here, it uses a plain QStyleOption.
ControlElement | Option Cast | Style Flag | Remark |
---|---|---|---|
CE_MenuItem, CE_MenuBarItem | QStyleOptionMenuItem | State_Selected | The menu item is currently selected item |
State_Enabled | The item is enabled | ||
State_DownArrow | Set if the menu item is down (i.e., if the mouse button or the space bar is pressed) | ||
State_HasFocus | Set if the menubar has input focus | ||
CE_PushButton, CE_PushButtonLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled |
State_HasFocus | Set if the button has input focus | ||
State_Raised | Set if the button is not down, not on and not flat | ||
State_On | Set if the button is a toggle button and is toggled on | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button) | ||
CE_RadioButton, CE_RadioButtonLabel, CE_CheckBox, CE_CheckBoxLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled |
State_HasFocus | Set if the button has input focus | ||
State_On | Set if the button is checked | ||
State_Off | Set if the button is not checked | ||
State_NoChange | Set if the button is in the NoChange state | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button) | ||
CE_ProgressBarContents, CE_ProgressBarLabel, CE_ProgressBarGroove | QStyleOptionProgressBar | State_Enabled | Set if the progressbar is enabled |
State_HasFocus | Set if the progressbar has input focus | ||
CE_Header, CE_HeaderSection, CE_HeaderLabel | QStyleOptionHeader | ||
CE_ToolButtonLabel | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled |
State_HasFocus | Set if the tool button has input focus | ||
State_Sunken | Set if the tool button is down (i.e., a mouse button or the space bar is pressed) | ||
State_On | Set if the tool button is a toggle button and is toggled on | ||
State_AutoRaise | Set if the tool button has auto-raise enabled | ||
State_MouseOver | Set if the mouse pointer is over the tool button | ||
State_Raised | Set if the button is not down and is not on | ||
CE_ToolBoxTab | QStyleOptionToolBox | State_Selected | The tab is the currently selected tab |
CE_HeaderSection | QStyleOptionHeader | State_Sunken | Indicates that the section is pressed. |
State_UpArrow | Indicates that the sort indicator should be pointing up. | ||
State_DownArrow | Indicates that the sort indicator should be pointing down. |
See also ControlElement, State, and QStyleOption.
Draws the pixmap in rectangle rect with alignment alignment using painter.
Draws the text in rectangle rect using painter and palette pal.
Text is drawn using the painter's pen. If an explicit textRole is specified, then the text is drawn using the color specified in pal for the specified role. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.
The text is aligned and wrapped according to alignment.
See also Qt::Alignment.
Draw the primitive option elem with painter using the style options specified by option.
The widget argument is optional and may contain a widget that may aid in drawing the primitive.
What follows is a table of the elements and the QStyleOption structure the option parameter can be cast to. The flags stored in the QStyleOption state variable are also listed. If a PrimitiveElement is not listed here, it uses a plain QStyleOption.
The QStyleOption is the the following for the following types of PrimitiveElements.
See also PrimitiveElement, State, and QStyleOption.
Returns a pixmap styled to conform to iconMode description out of pixmap, and taking into account the palette specified by option.
The option can pass extra information, but it must contain a palette.
Not all types of pixmaps will change from their input in which case the result will simply be the pixmap passed in.
Returns the SubControl in the ComplexControl control with the style options specified by option at the point pos. The option argument is a pointer to a QStyleOptionComplex structure or one of its subclasses. The structure can be cast to the appropriate type based on the value of control. See drawComplexControl() for details.
The widget argument is optional and can contain additional information for the functions.
Note that pos is expressed in screen coordinates.
See also drawComplexControl(), ComplexControl, SubControl, subControlRect(), and QStyleOptionComplex.
Returns the appropriate area within rectangle rect in which to draw the pixmap with alignment defined in alignment.
Returns the appropriate area (see below) within rectangle rect in which to draw text using the font metrics metrics.
The text is aligned in accordance with alignment. The enabled bool indicates whether or not the item is enabled.
If rect is larger than the area needed to render the text the rectangle that is returned will be offset within rect in accordance with the alignment alignment. For example, if alignment is Qt::AlignCenter, the returned rectangle will be centered within rect. If rect is smaller than the area needed, the rectangle that is returned will be larger than rect (the smallest rectangle large enough to render the text).
See also Qt::Alignment.
Returns the pixel metric for the given metric. The option and widget can be used for calculating the metric. The option can be cast to the appropriate type based on the value of metric. Note that option may be zero even for PixelMetrics that can make use of option. See the table below for the appropriate option casts:
In general, the widget argument is not used.
Initializes the appearance of widget.
This function is called for every widget at some point after it has been fully created but just before it is shown for the very first time.
Reasonable actions in this function might be to call QWidget::setBackgroundMode() for the widget. An example of highly unreasonable use would be setting the geometry! Reimplementing this function gives you a back-door through which you can change the appearance of a widget. With Qt 4.0's style engine you will rarely need to write your own polish(); instead reimplement drawItem(), drawPrimitive(), etc.
The QWidget::inherits() function may provide enough information to allow class-specific customizations. But be careful not to hard-code things too much because new QStyle subclasses are expected to work reasonably with all current and future widgets.
See also unpolish().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Late initialization of the QApplication object app.
See also unpolish().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
The style may have certain requirements for color palettes. In this function it has the chance to change the palette pal according to these requirements.
See also QPalette and QApplication::setPalette().
Returns the size of styled object described in option based on the contents size contentsSize.
The option argument is a pointer to a QStyleOption or one of its subclasses. The option can be cast to the appropriate type based on the value of type. The widget widget is optional argument and can contain extra information used for calculating the size. See the table below for the appropriate option usage:
See also ContentsType and QStyleOption.
Converts logicalValue to a pixel position. min maps to 0, max maps to span and other values are distributed evenly in-between.
This function can handle the entire integer range without overflow, providing span is less than 4096.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set upsideDown to true to reverse this behavior.
See also sliderValueFromPosition().
Converts the pixel position pos to a value. 0 maps to min, span maps to max and other values are distributed evenly in-between.
This function can handle the entire integer range without overflow.
By default, this function assumes that the maximum value is on the right for horizontal items and on the bottom for vertical items. Set upsideDown to true to reverse this behavior.
See also sliderPositionFromValue().
Returns an icon for standardIcon.
The option argument can be used to pass extra information required when determining the icon.
The widget argument is optional and may contain a widget that may aid determining the icon.
Warning: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own icons in a QStyle subclass, add a slot called standardIconImplementation() to you subclass. The standardIcon() function will dynamically detect the slot and call it.
This function was introduced in Qt 4.1.
See also standardIconImplementation() and standardPixmap().
Returns an icon for standardIcon.
The option argument contains extra information required when determining the icon. The widget argument is optional and may contain a widget that may aid determining the icon.
The default implementation simply calls standardPixmap(standardIcon, option, widget).
Warning: Because of binary compatibility constraints, the standardIcon() function, introduced in Qt 4.1, isn't virtual. If you want to provide your own icons in a QStyle subclass, add a slot called standardIconImplementation() to your subclass. The standardIcon() function will dynamically detect the slot and call it.
This function was introduced in Qt 4.1.
See also standardIcon().
Returns the style's standard palette. On systems that support system colors, the style's standard palette is not used.
Returns a pixmap for standardPixmap.
The option argument can be used to pass extra information required when drawing the ControlElement.
The widget argument is optional and may contain a widget that may aid in drawing the control.
See also standardIcon().
Returns the style hint hint for widget described in the QStyleOption option. Currently returnData and widget are not used; they are provided for future enhancement. The option parameter is used only in SH_ComboBox_Popup, SH_ComboBox_LayoutDirection, and SH_GroupBox_TextLabelColor.
For an explanation of the return value, see StyleHint.
Returns the rectangle for the SubControl subControl in the ComplexControl control, with the style options specified by option in visual coordinates.
The option argument is a pointer to a QStyleOptionComplex or one of its subclasses. The structure can be cast to the appropriate type based on the value of control. See drawComplexControl() for details.
The widget is optional and can contain additional information for the function.
See also drawComplexControl(), ComplexControl, SubControl, and QStyleOptionComplex.
Returns the sub-area element as described in option in logical coordinates.
The widget argument is optional and may contain a widget that may aid determining the subRect.
The QStyleOption can be cast to the appropriate type based on the value of element. See the table below for the appropriate option casts:
See also SubElement and QStyleOption.
Undoes the initialization of widget widget's appearance.
This function is the counterpart to polish. It is called for every polished widget when the style is dynamically changed. The former style has to unpolish its settings before the new style can polish them again.
See also polish().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Undoes the polish of application app.
See also polish().
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with Qt::AlignAbsolute according to the layout direction. The other alignment flags are left untouched.
If no horizontal aligment was specified, the function returns the default alignment for the layout direction.
Returns the point logicalPos converted to screen coordinates based on direction. The boundingRect rectangle is used to perform the translation.
See also QWidget::layoutDirection.
Returns the rectangle logicalRect converted to screen coordinates based on direction. The boundingRect rectangle is used to perform the translation.
This function is provided to aid style implementors in supporting right-to-left desktops. It typically is used in subControlRect().
See also QWidget::layoutDirection.
Copyright © 2005 Trolltech | Trademarks | Qt 4.1.0 |