Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QStyle Class Reference

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.

- List of all members, including inherited members
- Obsolete members
- Compatibility members

### Public Types

- enum ComplexControl { CC_SpinBox, CC_ComboBox, CC_ScrollBar, CC_Slider, CC_ToolButton, ..., CC_CustomBase }
- enum ContentsType { CT_CheckBox, CT_ComboBox, CT_DialogButtons, CT_DockWindow, CT_Header, ..., CT_CustomBase }
- enum ControlElement { CE_PushButton, CE_PushButtonBevel, CE_PushButtonLabel, CE_DockWindowTitle, CE_Splitter, ..., CE_CustomBase }
- enum IconMode { IM_Disabled, IM_Active, IM_CustomBase }
- enum PixelMetric { PM_ButtonMargin, PM_ButtonDefaultIndicator, PM_MenuButtonIndicator, PM_ButtonShiftHorizontal, PM_ButtonShiftVertical, ..., PM_DefaultLayoutSpacing }
- enum PrimitiveElement { PE_PanelButtonCommand, PE_FrameDefaultDefault, PE_PanelButtonBevel, PE_PanelButtonTool, PE_IndicatorButtonDropDown, ..., PE_CustomBase }
- enum StandardPixmap { SP_TitleBarMinButton, SP_TitleBarMaxButton, SP_TitleBarCloseButton, SP_TitleBarNormalButton, SP_TitleBarShadeButton, ..., SP_CustomBase }
- enum StyleFlag { Style_None, Style_Default, Style_Enabled, Style_Raised, Style_Sunken, ..., Style_Editing }
- typedef StyleFlags
- enum StyleHint { SH_EtchDisabledText, SH_GUIStyle, SH_ScrollBar_BackgroundRole, SH_ScrollBar_MiddleClickAbsolutePosition, SH_ScrollBar_LeftClickAbsolutePosition, ..., SH_ToolButton_PopupDelay }
- enum SubControl { SC_None, SC_ScrollBarAddLine, SC_ScrollBarSubLine, SC_ScrollBarAddPage, SC_ScrollBarSubPage, ..., SC_All }
- typedef SubControls
- enum SubRect { SR_PushButtonContents, SR_PushButtonFocusRect, SR_CheckBoxIndicator, SR_CheckBoxContents, SR_CheckBoxFocusRect, ..., SR_PanelTab }

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- QStyle ()
- virtual ~QStyle ()
- virtual void drawComplexControl ( ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0 ) const = 0
- virtual void drawComplexControlMask ( ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0 ) const = 0
- virtual void drawControl ( ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const = 0
- virtual void drawControlMask ( ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const = 0
- virtual void drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QString & text, int len = -1, const QColor * penColor = 0 ) const
- virtual void drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QPixmap & pixmap, const QColor * penColor = 0 ) const
- void drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QPixmap & pixmap, const QString & text, int len = -1, const QColor * penColor = 0 ) const
- virtual void drawPrimitive ( PrimitiveElement elem, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const = 0
- virtual QPixmap generatedIconPixmap ( IconMode iconMode, const QPixmap & pixmap, const QStyleOption * option ) const = 0
- virtual QRect itemRect ( const QFontMetrics & metrics, const QRect & rect, int alignment, bool enabled, const QString & text, int len = -1 ) const
- virtual QRect itemRect ( const QRect & rect, int alignment, const QPixmap & pixmap ) const
- virtual int pixelMetric ( PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const = 0
- virtual void polish ( QWidget * widget )
- virtual void polish ( QApplication * app )
- virtual void polish ( QPalette & pal )
- virtual SubControl querySubControl ( ComplexControl control, const QStyleOptionComplex * option, const QPoint & pos, const QWidget * widget = 0 ) const = 0
- virtual QRect querySubControlMetrics ( ComplexControl control, const QStyleOptionComplex * option, SubControl subControl, const QWidget * widget = 0 ) const = 0
- virtual QSize sizeFromContents ( ContentsType type, const QStyleOption * option, const QSize & contentsSize, const QWidget * widget = 0 ) const = 0
- virtual QPixmap standardPixmap ( StandardPixmap standardPixmap, const QStyleOption * option = 0, const QWidget * widget = 0 ) const = 0
- virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const = 0
- virtual QRect subRect ( SubRect subRect, const QStyleOption * option, const QWidget * widget = 0 ) const = 0
- virtual void unPolish ( QWidget * widget )
- virtual void unPolish ( QApplication * app )

- 26 public functions inherited from QObject

### Public Slots

- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- Qt::Alignment horizontalAlignment ( Qt::LayoutDirection direction, Qt::Alignment alignment )
- int positionFromValue ( int min, int max, int logicalValue, int span, bool upsideDown = false )
- int valueFromPosition ( int min, int max, int pos, int span, bool upsideDown = false )
- QPoint visualPos ( Qt::LayoutDirection direction, const QRect & boundingRect, const QPoint & logicalPos )
- QRect visualRect ( Qt::LayoutDirection direction, const QRect & boundingRect, const QRect & logicalRect )

- 4 static public members inherited from QObject

### Protected Functions

- 7 protected functions inherited from QObject

## Detailed Description

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:

- Setting a Style
- Developing Style-Aware Custom Widgets
- Creating a Custom Style
- Using a Custom Style
- Right-to-Left Desktops

### Setting a Style

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().

### Developing Style-Aware Custom Widgets

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(), drawControlMask(), drawComplexControl(), and drawComplexControlMask().

Most QStyle draw functions take four arguments:

- an enum value specifying which graphical element to draw
- a QStyleOption specifying how and where to render that element
- a QPainter that should be used to draw the element
- a QWidget on which the drawing is performed (optional)

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.init(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);

### Creating a Custom Style

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 = qt_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`.

### Using a Custom Style

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;
            app.setMainWidget(&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.

### Right-to-Left Desktops

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::setReverseLayout() in your main().

The actual reverse layout is performed automatically when possible. However, for the sake of flexibility, the translation cannot be performed everywhere. The documentation for each QStyle function states whether the function expects (or returns) logical or screen coordinates. Using logical coordinates (in ComplexControls, for example) provides great flexibility in controlling the look of a widget. Use visualRect() when necessary to translate logical coordinates into screen coordinates for drawing.

See also QStyleOption and QStylePainter.

## Member Type Documentation

### enum QStyle::ComplexControl

This enum represents a ComplexControl. ComplexControls have different behavior depending upon where the user clicks on them or which keys are pressed.

`QStyle::CC_SpinBox` |
`QStyle::CC_ComboBox` |
`QStyle::CC_ScrollBar` |
`QStyle::CC_Slider` |
`QStyle::CC_ToolButton` |
`QStyle::CC_TitleBar` |
`QStyle::CC_ListView` |

`QStyle::CC_CustomBase` | Base value for custom ControlElements. Custom values must be greater than this value.

See also SubControl and drawComplexControl().

### enum QStyle::ContentsType

This enum represents a ContentsType. It is used to calculate sizes for the contents of various widgets.

`QStyle::CT_CheckBox` |
`QStyle::CT_ComboBox` |
`QStyle::CT_DialogButtons` |
`QStyle::CT_DockWindow` |
`QStyle::CT_Header` |
`QStyle::CT_HeaderSection` |
`QStyle::CT_LineEdit` |
`QStyle::CT_Menu` |
`QStyle::CT_Menu` |
`QStyle::CT_MenuBar` |
`QStyle::CT_MenuBarItem` |
`QStyle::CT_MenuItem` |
`QStyle::CT_ProgressBar` |
`QStyle::CT_PushButton` |
`QStyle::CT_RadioButton` |
`QStyle::CT_SizeGrip` |
`QStyle::CT_Slider` |
`QStyle::CT_SpinBox` |
`QStyle::CT_Splitter` |
`QStyle::CT_TabBarTab` |
`QStyle::CT_TabWidget` |
`QStyle::CT_ToolButton` |

`QStyle::CT_CustomBase` | Base value for custom ControlElements. Custom values must be greater than this value.

See also sizeFromContents().

### enum QStyle::ControlElement

This enum represents a ControlElement. A ControlElement is part of a widget that performs some action or displays information to the user.

`QStyle::CE_PushButton` | A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect
`QStyle::CE_PushButtonBevel` | The bevel and default indicator of a QPushButton.
`QStyle::CE_PushButtonLabel` | The label (icon with text or pixmap) of a QPushButton
`QStyle::CE_DockWindowTitle` | Dock window title.
`QStyle::CE_Splitter` | Splitter handle; see also QSplitter.
`QStyle::CE_CheckBox` | A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect
`QStyle::CE_CheckBoxLabel` | The label (text or pixmap) of a QCheckBox
`QStyle::CE_RadioButton` | A QRadioButton, draws a PE_ExclusiveRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect
`QStyle::CE_RadioButtonLabel` | The label (text or pixmap) of a QRadioButton
`QStyle::CE_TabBarTab` | The tab within a QTabBar (a QTab)
`QStyle::CE_TabBarLabel` | The label within a QTab
`QStyle::CE_ProgressBar` | A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel
`QStyle::CE_ProgressBarGroove` | The groove where the progress indicator is drawn in a QProgressBar
`QStyle::CE_ProgressBarContents` | The progress indicator of a QProgressBar
`QStyle::CE_ProgressBarLabel` | The text label of a QProgressBar
`QStyle::CE_ToolButtonLabel` | A tool button's label
`QStyle::CE_MenuBarItem` | A menu item in a QMenuBar
`QStyle::CE_MenuBarEmptyArea` | The empty area of a QMenuBar
`QStyle::CE_MenuItem` | A menu item in a QMenu
`QStyle::CE_MenuScroller` | Scrolling areas in a QMenu when the style supports scrolling
`QStyle::CE_MenuTearoff` | A menu item representing the tear off section of a QMenu
`QStyle::CE_MenuEmptyArea` | The area in a menu without menu items
`QStyle::CE_MenuVMargin` | The vertical extra space on the top/bottom of a menu
`QStyle::CE_MenuHMargin` | The horizontal extra space on the left/right of a menu
`QStyle::CE_DockWindowEmptyArea` | The empty area of a QDockWindow
`QStyle::CE_ToolBoxTab` | The toolbox's tab area
`QStyle::CE_HeaderLabel` | The header's label
`QStyle::CE_SizeGrip` | Window resize handle; see also QSizeGrip.
`QStyle::CE_ScrollBarAddLine` | Scroll bar line increase indicator. (i.e., scroll down); see also QScrollBar.
`QStyle::CE_ScrollBarSubLine` | Scroll bar line decrease indicator (i.e., scroll up).
`QStyle::CE_ScrollBarAddPage` | Scolllbar page increase indicator (i.e., page down).
`QStyle::CE_ScrollBarSubPage` | Scroll bar page decrease indicator (i.e., page up).
`QStyle::CE_ScrollBarSlider` | Scroll bar slider.
`QStyle::CE_ScrollBarFirst` | Scroll bar first line indicator (i.e., home).
`QStyle::CE_ScrollBarLast` | Scroll bar last line indicator (i.e., end).
`QStyle::CE_RubberBand` | Rubber band used in such things as iconview.
`QStyle::CE_SpinBoxSlider` | The optional slider part of a spin box.
`QStyle::CE_CustomBase` | Base value for custom ControlElements; custom values must be greater than this value

See also drawControl().

### enum QStyle::IconMode

This enum represents the effects performed on a pixmap to achieve a GUI style's perferred way of representing the image in different states.

`QStyle::IM_Disabled` | A disabled pixmap (drawn on disabled widgets)
`QStyle::IM_Active` | An active pixmap (drawn on active tool buttons and menu items)
`QStyle::IM_CustomBase` | Base value for custom PixmapTypes; custom values must be greater than this value

See also generatedIconPixmap().

### enum QStyle::PixelMetric

This enum represents a PixelMetric. A PixelMetric is a style dependent size represented as a single pixel value.

`QStyle::PM_ButtonMargin` | Amount of whitespace between push button labels and the frame
`QStyle::PM_ButtonDefaultIndicator` | Width of the default-button indicator frame
`QStyle::PM_MenuButtonIndicator` | Width of the menu button indicator proportional to the widget height
`QStyle::PM_ButtonShiftHorizontal` | Horizontal contents shift of a button when the button is down
`QStyle::PM_ButtonShiftVertical` | Vertical contents shift of a button when the button is down
`QStyle::PM_DefaultFrameWidth` | Default frame width (usually 2)
`QStyle::PM_SpinBoxFrameWidth` | Frame width of a spin box
`QStyle::PM_MDIFrameWidth` | Frame width of an MDI window
`QStyle::PM_MDIMinimizedWidth` | Width of a minimized MDI window
`QStyle::PM_MaximumDragDistance` | 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` | Width of a vertical scroll bar and the height of a horizontal scroll bar
`QStyle::PM_ScrollBarSliderMin` | The minimum height of a vertical scroll bar's slider and the minimum width of a horizontal scroll bar's slider
`QStyle::PM_SliderThickness` | Total slider thickness
`QStyle::PM_SliderControlThickness` | Thickness of the slider handle
`QStyle::PM_SliderLength` | Length of the slider
`QStyle::PM_SliderTickmarkOffset` | The offset between the tickmarks and the slider
`QStyle::PM_SliderSpaceAvailable` | The available space for the slider to move
`QStyle::PM_DockWindowSeparatorExtent` | Width of a separator in a horizontal dock window and the height of a separator in a vertical dock window
`QStyle::PM_DockWindowHandleExtent` | Width of the handle in a horizontal dock window and the height of the handle in a vertical dock window
`QStyle::PM_DockWindowFrameWidth` | Frame width of a dock window
`QStyle::PM_MenuBarPanelWidth` | Frame width of a menubar
`QStyle::PM_MenuBarItemSpacing` | Spacing between menubar items
`QStyle::PM_MenuBarHMargin` | Spacing between menubar items and top/bottom of bar
`QStyle::PM_MenuBarVMargin` | Spacing between menubar items and left/right of bar
`QStyle::PM_ToolBarFrameWidth` | Width of the frame around toolbars
`QStyle::PM_ToolBarHandleExtent` | Width of a toolbar handle in a horizontal toolbar and the height of the handle in a vertical toolbar
`QStyle::PM_ToolBarItemSpacing` | Spacing between toolbar items
`QStyle::PM_ToolBarSeparatorExtent` | Width of a toolbar separator in a horizontal toolbar and the height of a separator in a vertical toolbar
`QStyle::PM_ToolBarExtensionExtent` | Width of a toolbar extension button in a horizontal toolbar and the height of the button in a vertical toolbar
`QStyle::PM_TabBarTabOverlap` | Number of pixels the tabs should overlap
`QStyle::PM_TabBarTabHSpace` | Extra space added to the tab width
`QStyle::PM_TabBarTabVSpace` | Extra space added to the tab height
`QStyle::PM_TabBarBaseHeight` | Height of the area between the tab bar and the tab pages
`QStyle::PM_TabBarBaseOverlap` | Number of pixels the tab bar overlaps the tab bar base
`QStyle::PM_TabBarScrollButtonWidth` |
`QStyle::PM_TabBarTabShiftHorizontal` | Horizontal pixel shift when a tab is selected
`QStyle::PM_TabBarTabShiftVertical` | Vertical pixel shift when a tab is selected
`QStyle::PM_ProgressBarChunkWidth` | Width of a chunk in a progress bar indicator
`QStyle::PM_SplitterWidth` | Width of a splitter
`QStyle::PM_TitleBarHeight` | Height of the title bar
`QStyle::PM_IndicatorWidth` | Width of a check box indicator
`QStyle::PM_IndicatorHeight` | Height of a checkbox indicator
`QStyle::PM_ExclusiveIndicatorWidth` | Width of a radio button indicator
`QStyle::PM_ExclusiveIndicatorHeight` | Height of a radio button indicator
`QStyle::PM_MenuPanelWidth` | Border width (applied on all sides) for a QMenu
`QStyle::PM_MenuHMargin` | Additional border (used on left and right) for a QMenu
`QStyle::PM_MenuVMargin` | Additional border (used for bottom and top) for a QMenu
`QStyle::PM_MenuScrollerHeight` | Height of the scroller area in a QMenu
`QStyle::PM_MenuScrollerHeight` | Height of the scroller area in a QMenu
`QStyle::PM_MenuTearoffHeight` | Height of a tear off area in a QMenu
`QStyle::PM_MenuDesktopFrameWidth` |

`QStyle::PM_CheckListButtonSize` | Area (width/height) of the checkbox/radio button in a Q3CheckListItem
`QStyle::PM_CheckListControllerSize` | Area (width/height) of the controller in a Q3CheckListItem
`QStyle::PM_DialogButtonsSeparator` | Distance between buttons in a dialog buttons widget
`QStyle::PM_DialogButtonsButtonWidth` | Minimum width of a button in a dialog buttons widget
`QStyle::PM_DialogButtonsButtonHeight` | Minimum height of a button in a dialog buttons widget
`QStyle::PM_HeaderMarkSize` |
`QStyle::PM_HeaderGripMargin` |
`QStyle::PM_HeaderMargin` |
`QStyle::PM_SpinBoxSliderHeight` | The height of the optional spin box slider
`QStyle::PM_CustomBase` | Base value for custom ControlElements Custom values must be greater than this value
`QStyle::PM_DefaultToplevelMargin` |
`QStyle::PM_DefaultChildMargin` |
`QStyle::PM_DefaultLayoutSpacing` |

See also pixelMetric().

### enum QStyle::PrimitiveElement

This enum represents a style's PrimitiveElements. A PrimitiveElement is a common GUI element, such as a checkbox indicator or button bevel.

`QStyle::PE_PanelButtonCommand` | Button used to initiate an action, for example, a QPushButton.
`QStyle::PE_FrameDefaultDefault` | This frame around a default button, e.g. in a dialog.
`QStyle::PE_PanelButtonBevel` | Generic panel with a button bevel.
`QStyle::PE_PanelButtonTool` | Panel for a Tool button, used with QToolButton
`QStyle::PE_IndicatorButtonDropDown` | indicator for a drop down button, for example, a tool button that displays a menu.
`QStyle::PE_FrameFocusRect` | Generic focus indicator.
`QStyle::PE_IndicatorArrowUp` | Generic Up arrow.
`QStyle::PE_IndicatorArrowDown` | Generic Down arrow.
`QStyle::PE_IndicatorArrowRight` | Generic Right arrow.
`QStyle::PE_IndicatorArrowLeft` | Generic Left arrow.
`QStyle::PE_IndicatorSpinUp` | Up symbol for a spin widget, for example a QSpinBox.
`QStyle::PE_IndicatorSpinDown` | Down symbol for a spin widget.
`QStyle::PE_IndicatorSpinPlus` | Increase symbol for a spin widget.
`QStyle::PE_IndicatorSpinMinus` | Decrease symbol for a spin widget.
`QStyle::PE_IndicatorCheckBox` | On/off indicator, for example, a QCheckBox.
`QStyle::PE_IndicatorCheckBoxMask` | Bitmap mask for an indicator.
`QStyle::PE_IndicatorRadioButton` | Exclusive on/off indicator, for example, a QRadioButton.
`QStyle::PE_IndicatorRadioButtonMask` | Bitmap mask for an exclusive indicator.
`QStyle::PE_Q3DockWindowSeparator` | Item separator for Qt 3 compatible dock window and toolbar contents.
`QStyle::PE_IndicatorDockWindowResizeHandle` | Resize handle for dock windows.
`QStyle::PE_Frame` | Generic frame; see also QFrame.
`QStyle::PE_FrameMenu` | Frame for popup windows/menus; see also QMenu.
`QStyle::PE_PanelMenuBar` | Panel for menu bars.
`QStyle::PE_FrameDockWindow` | Panel frame for dock windows and toolbars.
`QStyle::PE_FrameTabWidget` | Frame for tab widgets.
`QStyle::PE_FrameLineEdit` | Panel frame for line edits.
`QStyle::PE_FrameGroupBox` | Panel frame around group boxes.
`QStyle::PE_PanelHeader` | Panel Section of a list or table header; see also QHeader.
`QStyle::PE_IndicatorHeaderArrow` | Arrow used to indicate sorting on a list or table header
`QStyle::PE_FrameStatusBar` | Frame for a section of a status bar; see also QStatusBar.
`QStyle::PE_FrameWindow` | Frame around a MDI window or a docking window.
`QStyle::PE_Q3Separator` | Qt 3 compatible generic separator.
`QStyle::PE_IndicatorCheckMark` | Generic check mark.
`QStyle::PE_IndicatorProgressBarChunk` | Section of a progress bar indicator; see also QProgressBar.
`QStyle::PE_Q3CheckListController` | Qt 3 compatible Controller part of a list view item.
`QStyle::PE_Q3CheckListIndicator` | Qt 3 compatible Checkbox part of a list view item.
`QStyle::PE_Q3CheckListExclusiveIndicator` | Qt 3 compatible Radio button part of a list view item.
`QStyle::PE_IndicatorBranch` | Lines used to represent the branch of a tree in a tree view.
`QStyle::PE_CustomBase` | 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().

### enum QStyle::StandardPixmap

This enum represents a StandardPixmap. A StandardPixmap is a pixmap that can follow some existing GUI style or guideline.

`QStyle::SP_TitleBarMinButton` | Minimize button on title bars (e.g., in QWorkspace)
`QStyle::SP_TitleBarMaxButton` | Maximize button on title bars
`QStyle::SP_TitleBarCloseButton` | Close button on title bars
`QStyle::SP_TitleBarNormalButton` | Normal (restore) button on title bars
`QStyle::SP_TitleBarShadeButton` | Shade button on title bars
`QStyle::SP_TitleBarUnshadeButton` | Unshade button on title bars
`QStyle::SP_MessageBoxInformation` | The "information" icon
`QStyle::SP_MessageBoxWarning` | The "warning" icon
`QStyle::SP_MessageBoxCritical` | The "critical" icon
`QStyle::SP_MessageBoxQuestion` | The "question" icon
`QStyle::SP_DesktopIcon` |
`QStyle::SP_TrashIcon` |
`QStyle::SP_ComputerIcon` |
`QStyle::SP_DriveFDIcon` |
`QStyle::SP_DriveHDIcon` |
`QStyle::SP_DriveCDIcon` |
`QStyle::SP_DriveDVDIcon` |
`QStyle::SP_DriveNetIcon` |
`QStyle::SP_DirOpenIcon` |
`QStyle::SP_DirClosedIcon` |
`QStyle::SP_DirLinkIcon` |
`QStyle::SP_FileIcon` |
`QStyle::SP_FileLinkIcon` |
`QStyle::SP_DockWindowCloseButton` | Close button on dock windows (see also QDockWindow)
`QStyle::SP_ToolBarHorizontalExtensionButton` | Extension button for horizontal toolbars
`QStyle::SP_ToolBarVerticalExtensionButton` | Extension button for vertical toolbars
`QStyle::SP_CustomBase` | Base value for custom ControlElements; custom values must be greater than this value

See also standardPixmap().

### enum QStyle::StyleFlag
typedef QStyle::StyleFlags

The StyleFlags typedef can store a combination of StyleFlag values.

### enum QStyle::StyleHint

This enum represents a StyleHint. A StyleHint is a general look and/or feel hint.

`QStyle::SH_EtchDisabledText` | Disabled text is "etched" as it is on Windows.
`QStyle::SH_GUIStyle` | The GUI style to use.
`QStyle::SH_ScrollBar_BackgroundRole` | The background role for a QScrollBar.
`QStyle::SH_ScrollBar_MiddleClickAbsolutePosition` | 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` | 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` | 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_TabBar_Alignment` | The alignment for tabs in a QTabWidget. Possible values are `Qt::AlignLeft`, `Qt::AlignCenter` and `Qt::AlignRight`.
`QStyle::SH_Header_ArrowAlignment` | 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` | Sliders snap to values while moving, as they do on Windows.
`QStyle::SH_Slider_SloppyKeyEvents` | Key presses handled in a sloppy manner, i.e., left on a vertical slider subtracts a line.
`QStyle::SH_ProgressDialog_CenterCancelButton` | Center button on progress dialogs, like Motif, otherwise right aligned.
`QStyle::SH_ProgressDialog_TextLabelAlignment` | Type Qt::Alignment. Text label alignment in progress dialogs; Qt::Center on windows, Qt::VCenter otherwise.
`QStyle::SH_PrintDialog_RightAlignButtons` | Right align buttons in the print dialog, as done on Windows.
`QStyle::SH_MainWindow_SpaceBelowMenuBar` | One or two pixel space between the menubar and the dockarea, as done on Windows.
`QStyle::SH_FontDialog_SelectAssociatedText` | 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` | Allows disabled menu items to be active.
`QStyle::SH_Menu_SpaceActivatesItem` | Pressing the space bar activates the item, as done on Motif.
`QStyle::SH_Menu_SubMenuPopupDelay` | The number of milliseconds to wait before opening a submenu (256 on windows, 96 on Motif).
`QStyle::SH_Menu_Scrollable` | Whether popup menus must support scrolling.
`QStyle::SH_Menu_SloppySubMenus` | Whether popupmenu's must support sloppy submenu; as implemented on Mac OS.
`QStyle::SH_ScrollView_FrameOnlyAroundContents` | Whether scrollviews draw their frame only around contents (like Motif), or around contents, scroll bars and corner widgets (like Windows).
`QStyle::SH_MenuBar_AltKeyNavigation` | Menu bars items are navigable by pressing Alt, followed by using the arrow keys to select the desired item.
`QStyle::SH_ComboBox_ListMouseTracking` | Mouse tracking in combobox drop-down lists.
`QStyle::SH_Menu_MouseTracking` | Mouse tracking in popup menus.
`QStyle::SH_MenuBar_MouseTracking` | Mouse tracking in menubars.
`QStyle::SH_Menu_FillScreenWithScroll` | Whether scrolling popups should fill the screen as they are scrolled.
`QStyle::SH_ItemView_ChangeHighlightOnFocus` | Gray out selected items when losing focus.
`QStyle::SH_Widget_ShareActivation` | Turn on sharing activation with floating modeless dialogs.
`QStyle::SH_TabBar_SelectMouseType` | Which type of mouse event should cause a tab to be selected.
`QStyle::SH_ListViewExpand_SelectMouseType` | Which type of mouse event should cause a list view expansion to be selected.
`QStyle::SH_TabBar_PreferNoArrows` | Whether a tabbar should suggest a size to prevent scoll arrows.
`QStyle::SH_ComboBox_Popup` | Allows popups as a combobox drop-down menu.
`QStyle::SH_Workspace_FillSpaceOnMaximize` | The workspace should maximize the client area.
`QStyle::SH_TitleBar_NoBorder` | The title bar has no border.
`QStyle::SH_ScrollBar_StopMouseOverSlider` | Stops auto-repeat when the slider reaches the mouse position.
`QStyle::SH_BlinkCursorWhenTextSelected` | Whether cursor should blink when text is selected.
`QStyle::SH_RichText_FullWidthSelection` | Whether richtext selections should extend to the full width of the document.
`QStyle::SH_GroupBox_TextLabelVerticalAlignment` | How to vertically align a groupbox's text label.
`QStyle::SH_GroupBox_TextLabelColor` | How to paint a groupbox's text label.
`QStyle::SH_DialogButtons_DefaultButton` | Which button gets the default status in a dialog's button widget.
`QStyle::SH_ToolBox_SelectedPageTitleBold` | Boldness of the selected page title in a QToolBox.
`QStyle::SH_LineEdit_PasswordCharacter` | The Unicode character to be used for passwords.
`QStyle::SH_Table_GridLineColor` |

`QStyle::SH_UnderlineShortcut` | Whether shortcuts are underlined.
`QStyle::SH_SpinBox_AnimateButton` | Animate a click when up or down is pressed in a spin box.
`QStyle::SH_SpinBox_KeyPressAutoRepeatRate` | Auto-repeat interval for spinbox key presses.
`QStyle::SH_SpinBox_ClickAutoRepeatRate` | Auto-repeat interval for spinbox mouse clicks.
`QStyle::SH_TipLabel_Opacity` | An integer indicating the opacity for the tip label, 0 is completely transparent, 255 is completely opaque.
`QStyle::SH_DrawMenuBarSeparator` | Indicates whether or not the menubar draws separators.
`QStyle::SH_TitlebarModifyNotification` | Indicates if the titlebar should show a '*' for windows that are modified.
`QStyle::SH_Button_FocusPolicy` | The default focus policy for buttons.
`QStyle::SH_ColorDialog_SelectedColorBorder` | The border drawn around a selected color in a color dialog.
`QStyle::SH_CustomBase` | Base value for custom ControlElements. Custom values must be greater than this value.
`QStyle::SH_MenuBar_DismissOnSecondClick` | 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` | 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` | A boolean indicating whether controls on a title bar ought to update when the mouse is over them.
`QStyle::SH_ToolButton_PopupDelay` | An int indicating the popup delay in milliseconds for menus attached to tool buttons.

See also styleHint().

### enum QStyle::SubControl
typedef QStyle::SubControls

This enum represents a SubControl within a ComplexControl.

`QStyle::SC_None` | Special value that matches no other SubControl.
`QStyle::SC_ScrollBarAddLine` | Scroll bar add line (i.e., down/right arrow); see also QScrollBar
`QStyle::SC_ScrollBarSubLine` | Scroll bar sub line (i.e., up/left arrow)
`QStyle::SC_ScrollBarAddPage` | Scroll bar add page (i.e., page down)
`QStyle::SC_ScrollBarSubPage` | Scroll bar sub page (i.e., page up)
`QStyle::SC_ScrollBarFirst` | Scroll bar first line (i.e., home)
`QStyle::SC_ScrollBarLast` | Scroll bar last line (i.e., end)
`QStyle::SC_ScrollBarSlider` | Scroll bar slider handle
`QStyle::SC_ScrollBarGroove` | Special sub-control which contains the area in which the slider handle may move
`QStyle::SC_SpinBoxUp` | Spinwidget up/increase; see also QSpinBox
`QStyle::SC_SpinBoxDown` | Spinwidget down/decrease
`QStyle::SC_SpinBoxFrame` | Spinwidget frame
`QStyle::SC_SpinBoxEditField` | Spinwidget edit field
`QStyle::SC_SpinBoxButtonField` | Spinwidget button field
`QStyle::SC_SpinBoxSlider` | Spinwidget optional slider
`QStyle::SC_ComboBoxEditField` | Combobox edit field; see also QComboBox
`QStyle::SC_ComboBoxArrow` | Combobox arrow
`QStyle::SC_ComboBoxFrame` | Combobox frame
`QStyle::SC_ComboBoxListBoxPopup` | Combobox list box
`QStyle::SC_SliderGroove` | Special sub-control which contains the area in which the slider handle may move
`QStyle::SC_SliderHandle` | Slider handle
`QStyle::SC_SliderTickmarks` | Slider tickmarks
`QStyle::SC_ToolButton` | Tool button (see also QToolButton)
`QStyle::SC_ToolButtonMenu` | Sub-control for opening a popup menu in a tool button; see also Q3PopupMenu
`QStyle::SC_TitleBarSysMenu` | System menu button (i.e., restore, close, etc.)
`QStyle::SC_TitleBarMinButton` | Minimize button
`QStyle::SC_TitleBarMaxButton` | Maximize button
`QStyle::SC_TitleBarCloseButton` | Close button
`QStyle::SC_TitleBarLabel` | Window title label
`QStyle::SC_TitleBarNormalButton` | Normal (restore) button
`QStyle::SC_TitleBarShadeButton` | Shade button
`QStyle::SC_TitleBarUnshadeButton` | Unshade button
`QStyle::SC_TitleBarContextHelp` | Context Help button
`QStyle::SC_ListView` | The list view area
`QStyle::SC_ListViewExpand` | Expand item (i.e., show/hide child items)
`QStyle::SC_All` | Special value that matches all SubControls

The SubControls typedef can store a combination of SubControl values.

See also ComplexControl.

### enum QStyle::SubRect

This enum represents a sub-area of a widget. Style implementations use these areas to draw the different parts of a widget.

`QStyle::SR_PushButtonContents` | Area containing the label (icon with text or pixmap)
`QStyle::SR_PushButtonFocusRect` | Area for the focus rect (usually larger than the contents rect)
`QStyle::SR_CheckBoxIndicator` | Area for the state indicator (e.g., check mark)
`QStyle::SR_CheckBoxContents` | Area for the label (text or pixmap)
`QStyle::SR_CheckBoxFocusRect` | Area for the focus indicator
`QStyle::SR_RadioButtonIndicator` | Area for the state indicator
`QStyle::SR_RadioButtonContents` | Area for the label
`QStyle::SR_RadioButtonFocusRect` | Area for the focus indicator
`QStyle::SR_ComboBoxFocusRect` | Area for the focus indicator
`QStyle::SR_SliderFocusRect` | Area for the focus indicator
`QStyle::SR_DockWindowHandleRect` | Area for the tear-off handle
`QStyle::SR_ProgressBarGroove` | Area for the groove
`QStyle::SR_ProgressBarContents` | Area for the progress indicator
`QStyle::SR_ProgressBarLabel` | Area for the text label
`QStyle::SR_ToolButtonContents` | Area for the tool button's label
`QStyle::SR_DialogButtonAccept` | Area for a dialog's accept button
`QStyle::SR_DialogButtonReject` | Area for a dialog's reject button
`QStyle::SR_DialogButtonApply` | Area for a dialog's apply button
`QStyle::SR_DialogButtonHelp` | Area for a dialog's help button
`QStyle::SR_DialogButtonAll` | Area for a dialog's all button
`QStyle::SR_DialogButtonRetry` | Area for a dialog's retry button
`QStyle::SR_DialogButtonAbort` | Area for a dialog's abort button
`QStyle::SR_DialogButtonIgnore` | Area for a dialog's ignore button
`QStyle::SR_DialogButtonCustom` | Area for a dialog's custom widget area (in the button row)
`QStyle::SR_ToolBoxTabContents` | Area for a toolbox tab's icon and label
`QStyle::SR_CustomBase` | Base value for custom ControlElements Custom values must be greater than this value
`QStyle::SR_HeaderArrow` |
`QStyle::SR_HeaderLabel` |

`QStyle::SR_PanelTab` |

See also subRect().

## Member Function Documentation

### QStyle::QStyle ()

Constructs a style object.

### QStyle::~QStyle () `[virtual]`

Destroys the style object.

### void QStyle::drawComplexControl ( ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0 ) const `[pure virtual]`

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 | Style_Enabled | Set if the spin box is enabled
Style_HasFocus | Set if the spin box has input focus
CC_ComboBox | QStyleOptionComboBox | Style_Enabled | Set if the combobox is enabled
Style_HasFocus | Set if the combobox has input focus
CC_ScrollBar | QStyleOptionSlider | Style_Enabled | Set if the scroll bar is enabled
Style_HasFocus | Set if the scroll bar has input focus
CC_Slider | QStyleOptionSlider | Style_Enabled | Set if the slider is enabled
Style_HasFocus | Set if the slider has input focus
CC_ToolButton | QStyleOptionToolButton | Style_Enabled | Set if the tool button is enabled
Style_HasFocus | Set if the tool button has input focus
Style_Down | Set if the tool button is down (i.e., a mouse button or the space bar is pressed)
Style_On | Set if the tool button is a toggle button and is toggled on
Style_AutoRaise | Set if the tool button has auto-raise enabled
Style_Raised | Set if the button is not down, not on, and doesn't contain the mouse when auto-raise is enabled
CC_TitleBar | QStyleOptionTitleBar | Style_Enabled | Set if the title bar is enabled
CC_ListView | QStyleOptionListView | Style_Enabled | Set if the list view is enabled

See also ComplexControl, SubControl, and QStyleOptionComplex.

### void QStyle::drawComplexControlMask ( ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0 ) const `[pure virtual]`

Draws a bitmask for the ComplexControl control using painter with the style options specified by option. See drawComplexControl() for an explanation of the use of the widget and option arguments.

The `rect` member of the QStyleOptionComplex option parameter should be expressed in logical coordinates. Reimplementations of this function can use visualRect() to convert the logical coordinates into screen coordinates before calling drawPrimitive() or drawControl().

See also drawComplexControl(), ComplexControl, and QStyleOptionComplex.

### void QStyle::drawControl ( ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const `[pure virtual]`

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 | Style_Selected | The menu item is currently selected item
Style_Enabled | The item is enabled
Style_Down | Set if the menu item is down (i.e., if the mouse button or the space bar is pressed)
Style_HasFocus | Set if the menubar has input focus
CE_PushButton, CE_PushButtonLabel | QStyleOptionButton | Style_Enabled | Set if the button is enabled
Style_HasFocus | Set if the button has input focus
Style_Raised | Set if the button is not down, not on and not flat
Style_On | Set if the button is a toggle button and is toggled on
Style_Down | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button)
Style_ButtonDefault | Set if the button is a default button
CE_RadioButton, CE_RadioButtonLabel, CE_CheckBox, CE_CheckBoxLabel | QStyleOptionButton | Style_Enabled | Set if the button is enabled
Style_HasFocus | Set if the button has input focus
Style_On | Set if the button is checked
Style_Off | Set if the button is not checked
Style_NoChange | Set if the button is in the NoChange state
Style_Down | 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 | Style_Enabled | Set if the progressbar is enabled
Style_HasFocus | Set if the progressbar has input focus
CE_HeaderLabel | QStyleOptionHeader |  |
CE_ToolButtonLabel | QStyleOptionToolButton | Style_Enabled | Set if the tool button is enabled
Style_HasFocus | Set if the tool button has input focus
Style_Down | Set if the tool button is down (i.e., a mouse button or the space bar is pressed)
Style_On | Set if the tool button is a toggle button and is toggled on
Style_AutoRaise | Set if the tool button has auto-raise enabled
Style_MouseOver | Set if the mouse pointer is over the tool button
Style_Raised | Set if the button is not down and is not on
CE_ToolBoxTab | QStyleOptionToolBox | Style_Selected | The tab is the currently selected tab

See also ControlElement, StyleFlags, and QStyleOption.

### void QStyle::drawControlMask ( ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const `[pure virtual]`

Draw a bitmask for the ControlElement element using the painter with the style options specified by option. See drawControl() for an explanation of the use of option and widget.

### void QStyle::drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QString & text, int len = -1, const QColor * penColor = 0 ) const `[virtual]`

Draws the text in rectangle rect using painter and palette pal.

The pen color is specified with penColor. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.

If len is -1 (the default), all the text is drawn; otherwise only the first len characters of text are drawn. The text is aligned and wrapped according to alignment.

See also Qt::Alignment.

### void QStyle::drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QPixmap & pixmap, const QColor * penColor = 0 ) const `[virtual]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the pixmap in rectangle rect using painter and the palette pal.

### void QStyle::drawItem ( QPainter * painter, const QRect & rect, int alignment, const QPalette & pal, bool enabled, const QPixmap & pixmap, const QString & text, int len = -1, const QColor * penColor = 0 ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the pixmap in rectangle rect using painter and palette pal.

### void QStyle::drawPrimitive ( PrimitiveElement elem, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0 ) const `[pure virtual]`

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.

PrimitiveElement | Option Cast | Style Flag | Remark
--- | --- | --- | ---
PE_FrameFocusRect | QStyleOptionFocusRect | Style_FocusAtBorder | Whether the focus is is at the border or inside the widget.
PE_IndicatorCheckBox | QStyleOptionButton | Sytle_NoChange | Indicates a "tri-state" checkbox.
Style_On | Indicates the indicator is checked.
PE_IndicatorRadioButton | QStyleOptionButton | Style_On | Indicates that a radio button is selected.
PE_Q3CheckListExclusiveIndicator, PE_CheckListIndicator | QStyleOptionListView | Style_On | Indicates whether or not the controller is selected.
Style_NoChange | Indicates a "tri-state" controller.
Style_Enable | Indicates the controller is enabled.
PE_TreeBranch | QStyleOption | Style_Down | Indicates that the Tree Branch is pressed
Style_Open | Indicates that the tree branch is expanded.
PE_IndicatorHeaderArrow | QStyleOptionHeader | Style_Up | Indicates that the arrow should be drawn up; otherwise it should be down.
PE_PanelHeaderSection | QStyleOptionHeader | Style_Sunken | Indicates that the section is pressed.
Style_Up | Indicates that the sort indicator should be pointing up.
Style_Off | Indicates that the the section is not selected.
PE_PanelGroupBox, PE_Panel, PE_PanelLineEdit, PE_PanelPopup, PE_PanelDockWindow | QStyleOptionFrame | Style_Sunken | Indicates that the Frame should be sunken.
PE_Q3DockWindowHandle | QStyleOptionDockWindow | Style_Horizontal | Indicates that the window handle is horizontal instead of vertical.
PE_Q3DockWindowSeparator | QStyleOption | Style_Horizontal | Indicates that the separator is horizontal instead of vertical.
PE_IndicatorSpinPlus, PE_IndicatorSpinMinus, PE_IndicatorSpinUp, PE_IndicatorSpinDown, | QStyleOptionSpinBox | Style_Sunken | Indicates that the button is pressed.

See also PrimitiveElement, StyleFlags, and QStyleOption.

### QPixmap QStyle::generatedIconPixmap ( IconMode iconMode, const QPixmap & pixmap, const QStyleOption * option ) const `[pure virtual]`

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.

### Qt::Alignment QStyle::horizontalAlignment ( Qt::LayoutDirection direction, Qt::Alignment alignment ) `[static]`

Strips out vertical alignment flags and transforms an alignment of Qt::AlignAuto into Qt::AlignLeft or Qt::AlignRight according to the layout direction. The other horizontal alignment flags are left untouched.

QWidget::layoutDirection

### QRect QStyle::itemRect ( const QFontMetrics & metrics, const QRect & rect, int alignment, bool enabled, const QString & text, int len = -1 ) const `[virtual]`

Returns the appropriate area (see below) within rectangle rect in which to draw text using the font metrics metrics.

If len is -1 (the default) all the text is drawn; otherwise only the first len characters of text are drawn. 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.

### QRect QStyle::itemRect ( const QRect & rect, int alignment, const QPixmap & pixmap ) const `[virtual]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the appropriate area within rectangle rect in which to draw the pixmap.

### int QStyle::pixelMetric ( PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const `[pure virtual]`

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:

PixelMetric | Option Cast
--- | ---
PM_SliderControlThickness | QStyleOptionSlider
PM_SliderLength | QStyleOptionSlider
PM_SliderTickmarkOffset | QStyleOptionSlider
PM_SliderSpaceAvailable | QStyleOptionSlider
PM_ScrollBarExtent | QStyleOptionSlider
PM_TabBarTabOverlap | QStyleOptionTab
PM_TabBarTabHSpace | QStyleOptionTab
PM_TabBarTabVSpace | QStyleOptionTab
PM_TabBarBaseHeight | QStyleOptionTab
PM_TabBarBaseOverlap | QStyleOptionTab

In general, the widget argument is not used.

### void QStyle::polish ( QWidget * widget ) `[virtual]`

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().

### void QStyle::polish ( QApplication * app ) `[virtual]`

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().

### void QStyle::polish ( QPalette & pal ) `[virtual]`

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().

### int QStyle::positionFromValue ( int min, int max, int logicalValue, int span, bool upsideDown = false ) `[static]`

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 valueFromPosition().

### SubControl QStyle::querySubControl ( ComplexControl control, const QStyleOptionComplex * option, const QPoint & pos, const QWidget * widget = 0 ) const `[pure virtual]`

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. When using querySubControlMetrics() to check for hits and misses, use visualRect() to change the logical coordinates into screen coordinates.

See also drawComplexControl(), ComplexControl, SubControl, querySubControlMetrics(), and QStyleOptionComplex.

### QRect QStyle::querySubControlMetrics ( ComplexControl control, const QStyleOptionComplex * option, SubControl subControl, const QWidget * widget = 0 ) const `[pure virtual]`

Returns the rectangle for the SubControl subControl in the ComplexControl control, with the style options specified by option in logical 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.

### QSize QStyle::sizeFromContents ( ContentsType type, const QStyleOption * option, const QSize & contentsSize, const QWidget * widget = 0 ) const `[pure virtual]`

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:

ContentsType | Option Cast
--- | ---
CT_PushButton | QStyleOptionButton
CT_CheckBox | QStyleOptionButton
CT_RadioButton | QStyleOptionButton
CT_ToolButton | QStyleOptionToolButton
CT_ComboBox | QStyleOptionComboBox
CT_Splitter | QStyleOption
CT_DockWindow | QStyleOptionDockWindow
CT_ProgressBar | QStyleOptionProgressBar
CT_MenuItem | QStyleOptionMenuItem

See also ContentsType and QStyleOption.

### QPixmap QStyle::standardPixmap ( StandardPixmap standardPixmap, const QStyleOption * option = 0, const QWidget * widget = 0 ) const `[pure virtual]`

Returns a pixmap for standardPixmap.

The option argument can be used to pass extra information required when drawing the ControlElement. Currently, the option argument is unused.

The widget argument is optional and may contain a widget that may aid in drawing the control.

### int QStyle::styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const `[pure virtual]`

Returns the style hint hint for widget descriped in the QStyleOption option. Currently returnData and widget are not used; they are provided for future enhancement. The option parameters is used only in SH_ComboBox_Popup and SH_GroupBox_TextLabelColor.

For an explanation of the return value, see StyleHint.

### QRect QStyle::subRect ( SubRect subRect, const QStyleOption * option, const QWidget * widget = 0 ) const `[pure virtual]`

Returns the sub-area subRect as described in option in logical coordinates.

The metrics argument may be helpful in determining the size of the sub-area.

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 subRect. See the table below for the appropriate widget casts:

SubRect | Option Cast
--- | ---
SR_PushButtonContents | QStyleOptionButton
SR_PushButtonFocusRect | QStyleOptionButton
SR_CheckBoxIndicator | QStyleOptionButton
SR_CheckBoxContents | QStyleOptionButton
SR_CheckBoxFocusRect | QStyleOptionButton
SR_RadioButtonIndicator | QStyleOptionButton
SR_RadioButtonContents | QStyleOptionButton
SR_RadioButtonFocusRect | QStyleOptionButton
SR_ComboBoxFocusRect | QStyleOptionComboBox
SR_DockWindowHandleRect | QStyleOptionDockWindow
SR_ProgressBarGroove | QStyleOptionProgressBar
SR_ProgressBarContents | QStyleOptionProgressBar
SR_ProgressBarLabel | QStyleOptionProgressBar

See also SubRect and QStyleOption.

### void QStyle::unPolish ( QWidget * widget ) `[virtual]`

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().

### void QStyle::unPolish ( QApplication * app ) `[virtual]`

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().

### int QStyle::valueFromPosition ( int min, int max, int pos, int span, bool upsideDown = false ) `[static]`

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 positionFromValue().

### QPoint QStyle::visualPos ( Qt::LayoutDirection direction, const QRect & boundingRect, const QPoint & logicalPos ) `[static]`

Returns the point logicalPos converted to screen coordinates. The boundingRect rectangle is used to perform the translation.

This function is provided to aid style implementors in supporting right-to-left desktops.

See also QWidget::layoutDirection.

### QRect QStyle::visualRect ( Qt::LayoutDirection direction, const QRect & boundingRect, const QRect & logicalRect ) `[static]`

Returns the rectangle logicalRect converted to screen coordinates. The boundingRect rectangle is used to perform the translation.

This function is provided to aid style implementors in supporting right-to-left desktops.

See also QWidget::layoutDirection.