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

QStyleOption Class Reference

The QStyleOption class and its sub-classes are used to describe the parameters used by QStyle functions. More...

#include <QStyleOption>

Inherited by QStyleOptionFocusRect, QStyleOptionFrame, QStyleOptionHeader, QStyleOptionButton, QStyleOptionTab, QStyleOptionProgressBar, QStyleOptionMenuItem, QStyleOptionComplex, QStyleOptionListViewItem, QStyleOptionDockWindow, QStyleOptionToolBox, and QStyleOptionViewItem.

List of all members.

Public Types

Read-Only Properties

Public Functions


Detailed Description

The QStyleOption class and its sub-classes are used to describe the parameters used by QStyle functions.

In previous Qt versions, many QStyle functions required a QWidget parameter of a certain type in order for it to work correctly. This coupled the QStyle closely to the widgets it was styling. In Qt 4.0, this restriction has been removed. Instead, a QStyleOption or one of its sub-classes supply the information the function needs.

QStyleOption and its sub-classes all have a version parameter. The current version is 0. This version number must be specified explicitly when creating the structure. The version number helps to ensure future expansion without ruining compatiblity with older styles.

Contrary to the rest of Qt, there are few member functions and the access to the variables is direct. The "low-level" feel makes the structures use straight forward and empahsizes that these are parameters used by the style functions, not clases. As a downside it forces developers to be careful to initialize all the variables.

QStyleOption and its sub-classes can be safely checked using the qt_cast() functions.


Member Type Documentation

enum QStyleOption::OptionType

This enum is used internally by the QStyleOption, its sub-classes and qt_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption sub-class.

QStyleOption::SO_DefaultIndicates a default QStyleOption
QStyleOption::SO_FocusRectIndicates a QStyleOptionFocusRect
QStyleOption::SO_ButtonIndicates a QStyleOptionButton
QStyleOption::SO_TabIndicates a QStyleOptionTab
QStyleOption::SO_MenuItemIndicates a QStyleOptionMenuItem
QStyleOption::SO_ComplexIndicates a QStyleOptionComplex
QStyleOption::SO_SliderIndicates a QStyleOptionSlider
QStyleOption::SO_FrameIndicates a QStyleOptionFrame
QStyleOption::SO_ProgressBarIndicates a QStyleOptionProgressBar
QStyleOption::SO_ListViewIndicates a QStyleOptionListView
QStyleOption::SO_ListViewItemIndicates a QStyleOptionListViewItem
QStyleOption::SO_HeaderIndicates a QStyleOptionHeader
QStyleOption::SO_DockWindowIndicates a QStyleOptionDockWindow
QStyleOption::SO_SpinBoxIndicates a QStyleOptionSpinBox
QStyleOption::SO_ToolButtonIndicates a QStyleOptionToolButton
QStyleOption::SO_ComboBoxIndicates a QStyleOptionComboBox
QStyleOption::SO_ToolBoxIndicates a QStyleOptionToolBox
QStyleOption::SO_TitleBarIndicates a QStyleOptionTitleBar
QStyleOption::SO_ViewItemIndicates a QStyleOptionViewItem (used in Interviews)
QStyleOption::SO_CustomBaseThis is reserved for custom QStyleOptions, all custom values must be above this value.

Property Documentation

palette : QPalette

This property holds the palette that should be used in when painting the control.

rect : QRect

This property holds the area that should be used for various calculations and painting.

This can have overloaded meanings. For example, for CE_PushButton it would be the rectangle for the entire button, while for CE_PushButtonLabel it would be just the area for the label.

state : QStyle::SFlags

This property holds the QStyle::StyleFlags that are used when drawing the control.

Several flags can be OR'd together. See drawControl and drawPrimitive for further information.

See also QStyle::drawPrimitive(), QStyle::drawControl(), QStyle::drawComplexControl(), and QStyle::StyleFlags.

type : int

This property holds the OptionType of the QStyleOption.

version : int

This property holds the version of the QStyleOption.

The current default is 0.


Member Function Documentation

QStyleOption::QStyleOption ( int optionversion, int optiontype = SO_Default )

Construct a QStyleOption with version optionversion and type optiontype. Usually, you will only pass optionversion. The optiontype parameter is mainly used by the subclasses for RTTI information.

void QStyleOption::init ( const QWidget * w )

A convenience function that intializes some of the variables in the QStyleOption structure based on the widget w.

The init() function assigns the rect and palette variables to w's rect() and palette() respectively. It also initializes the state variable checking if the widget is enabled and if it has focus.


Copyright © 2004 Trolltech. Trademarks
Qt 4.0.0-tp1