QStyle Class Reference
The API for this class is under development and is subject to change.
We do not recommend the use of this class for production work at this time.
The QStyle class specifies the look and feel of a GUI.
More...
#include <qstyle.h>
Inherits QObject.
Inherited by QCommonStyle.
List of all member functions.
Public Members
virtual void
polish ( QWidget * )
virtual void
polish ( QApplication * )
virtual void
unPolish ( QApplication * )
virtual void
polish ( QPalette & )
virtual QRect
itemRect ( QPainter * p, const QRect & r, int flags, bool enabled, const QPixmap * pixmap, const QString & text, int len = -1 ) const
virtual void
drawItem ( QPainter * p, const QRect & r, int flags, const QColorGroup & g, bool enabled, const QPixmap * pixmap, const QString & text, int len = -1, const QColor * penColor = 0 ) const
enum
PrimitiveElement { PE_ButtonCommand, PE_ButtonBevel, PE_ButtonTool, PE_ButtonDropDown, PE_FocusRect, PE_ArrowUp, PE_ArrowDown, PE_ArrowRight, PE_ArrowLeft, PE_SpinWidgetUp, PE_SpinWidgetDown, PE_SpinWidgetPlus, PE_SpinWidgetMinus, PE_Indicator, PE_IndicatorMask, PE_ExclusiveIndicator, PE_ExclusiveIndicatorMask, PE_DockWindowHandle, PE_DockWindowSeparator, PE_DockWindowResizeHandle, PE_Splitter, PE_Panel, PE_PanelPopup, PE_PanelMenuBar, PE_PanelDockWindow, PE_TabBarBase, PE_HeaderSection, PE_HeaderArrow, PE_StatusBarSection, PE_GroupBoxFrame, PE_Separator, PE_SizeGrip, PE_CheckMark, PE_ScrollBarAddLine, PE_ScrollBarSubLine, PE_ScrollBarAddPage, PE_ScrollBarSubPage, PE_ScrollBarSlider, PE_ScrollBarFirst, PE_ScrollBarLast, PE_ProgressBarChunk }
enum
PrimitiveElementFlags { PStyle_Default = 0x00000000, PStyle_Enabled = 0x00000001, PStyle_Raised = 0x00000002, PStyle_Sunken = 0x00000004, PStyle_Off = 0x00000008, PStyle_NoChange = 0x00000010, PStyle_On = 0x00000020, PStyle_Down = 0x00000040, PStyle_Horizontal = 0x00000080, PStyle_Vertical = 0x00000100, PStyle_HasFocus = 0x00000200, PStyle_Top = 0x00000400, PStyle_Bottom = 0x00000800, PStyle_FocusAtBorder = 0x00001000, PStyle_AutoRaise = 0x00002000, PStyle_MouseOver = 0x00004000, PStyle_Up = 0x00008000 }
typedef uint PFlags
virtual void
drawPrimitive ( PrimitiveElement op, QPainter * p, const QRect & r, const QColorGroup & cg, PFlags flags = PStyle_Default, void ** data = 0 ) const
enum
ControlElement { CE_PushButton, CE_PushButtonLabel, CE_CheckBox, CE_CheckBoxLabel, CE_RadioButton, CE_RadioButtonLabel, CE_TabBarTab, CE_TabBarLabel, CE_ProgressBarGroove, CE_ProgressBarContents, CE_ProgressBarLabel, CE_PopupMenuItem, CE_MenuBarItem }
enum
ControlElementFlags { CStyle_Default = 0x00000000, CStyle_Selected = 0x00000001, CStyle_HasFocus = 0x00000002, CStyle_Active = 0x00000004 }
typedef uint CFlags
virtual void
drawControl ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, CFlags how = CStyle_Default, void ** data = 0 ) const
virtual void
drawControlMask ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, void ** data = 0 ) const
enum
SubRect { SR_PushButtonContents, SR_PushButtonFocusRect, SR_CheckBoxIndicator, SR_CheckBoxContents, SR_CheckBoxFocusRect, SR_RadioButtonIndicator, SR_RadioButtonContents, SR_RadioButtonFocusRect, SR_ComboBoxFocusRect, SR_SliderFocusRect, SR_DockWindowHandleRect, SR_ProgressBarGroove, SR_ProgressBarContents, SR_ProgressBarLabel }
virtual QRect
subRect ( SubRect subrect, const QWidget * widget ) const
enum
ComplexControl { CC_SpinWidget, CC_ComboBox, CC_ScrollBar, CC_Slider, CC_ToolButton, CC_TitleBar, CC_ListView }
enum
SubControl { SC_None = 0x00000000, SC_ScrollBarAddLine = 0x00000001, SC_ScrollBarSubLine = 0x00000002, SC_ScrollBarAddPage = 0x00000004, SC_ScrollBarSubPage = 0x00000008, SC_ScrollBarFirst = 0x00000010, SC_ScrollBarLast = 0x00000020, SC_ScrollBarSlider = 0x00000040, SC_ScrollBarGroove = 0x00000080, SC_SpinWidgetUp = 0x00000001, SC_SpinWidgetDown = 0x00000002, SC_SpinWidgetFrame = 0x00000004, SC_SpinWidgetEditField = 0x00000008, SC_SpinWidgetButtonField = 0x00000010, SC_ComboBoxEditField = 0x00000001, SC_ComboBoxArrow = 0x00000002, SC_SliderGroove = 0x00000001, SC_SliderHandle = 0x00000002, SC_SliderTickmarks = 0x00000004, SC_ToolButton = 0x00000001, SC_ToolButtonMenu = 0x00000002, SC_TitleBarSysMenu = 0x00000001, SC_TitleBarMinButton = 0x00000002, SC_TitleBarMaxButton = 0x00000004, SC_TitleBarCloseButton = 0x00000008, SC_TitleBarLabel = 0x00000010, SC_TitleBarNormalButton = 0x00000020, SC_TitleBarShadeButton = 0x00000040, SC_TitleBarUnshadeButton = 0x00000080, SC_ListView = 0x00000001, SC_ListViewBranch = 0x00000002, SC_ListViewExpand = 0x00000004, SC_All = 0xffffffff }
typedef uint SCFlags
virtual void
drawComplexControl ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, CFlags flags = CStyle_Default, SCFlags sub = SC_All, SCFlags subActive = SC_None, void ** data = 0 ) const
virtual void
drawComplexControlMask ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, void ** data = 0 ) const
virtual QRect
querySubControlMetrics ( ComplexControl control, const QWidget * widget, SubControl subcontrol, void ** data = 0 ) const
virtual SubControl
querySubControl ( ComplexControl control, const QWidget * widget, const QPoint & pos, void ** data = 0 ) const
enum
PixelMetric { PM_ButtonMargin, PM_ButtonDefaultIndicator, PM_MenuButtonIndicator, PM_ButtonShiftHorizontal, PM_ButtonShiftVertical, PM_DefaultFrameWidth, PM_SpinBoxFrameWidth, PM_MaximumDragDistance, PM_ScrollBarExtent, PM_SliderThickness, PM_SliderControlThickness, PM_SliderLength, PM_SliderTickmarkOffset, PM_SliderSpaceAvailable, PM_DockWindowSeparatorExtent, PM_DockWindowHandleExtent, PM_DockWindowFrameWidth, PM_MenuBarFrameWidth, PM_TabBarTabOverlap, PM_TabBarTabHSpace, PM_TabBarTabVSpace, PM_TabBarBaseHeight, PM_TabBarBaseOverlap, PM_ProgressBarChunkWidth, PM_SplitterWidth, PM_IndicatorWidth, PM_IndicatorHeight, PM_ExclusiveIndicatorWidth, PM_ExclusiveIndicatorHeight }
virtual int
pixelMetric ( PixelMetric metric, const QWidget * widget = 0 ) const
enum
ContentsType { CT_PushButton, CT_CheckBox, CT_RadioButton, CT_ToolButton, CT_ComboBox, CT_Splitter, CT_DockWindow, CT_ProgressBar, CT_PopupMenuItem }
virtual QSize
sizeFromContents ( ContentsType contents, const QWidget * widget, const QSize & contentsSize, void ** data = 0 ) const
enum
StyleHint { SH_ScrollBar_BackgroundMode, SH_ScrollBar_MiddleClickAbsolutePosition, SH_ScrollBar_ScrollWhenPointerLeavesControl, SH_TabBar_Alignment, SH_Header_Arrow_Alignment }
virtual int
styleHint ( StyleHint stylehint, const QWidget * widget = 0, void *** returnData = 0 ) const
enum
StylePixmap { SP_TitleBarMinButton, SP_TitleBarMaxButton, SP_TitleBarCloseButton, SP_TitleBarNormalButton, SP_TitleBarShadeButton, SP_TitleBarUnshadeButton, SP_DockWindowCloseButton }
virtual QPixmap
stylePixmap ( StylePixmap stylepixmap, const QWidget * widget = 0, void ** data = 0 ) const
operator GUIStyle () const (obsolete)
bool operator== ( GUIStyle s ) const (obsolete)
bool operator!= ( GUIStyle s ) const (obsolete)
GUIStyle guiStyle () const (obsolete)
Static Public Members
QRect
visualRect ( const QRect & logical, const QWidget * w )
QRect
visualRect ( const QRect & logical, const QRect & bounding )
Detailed Description
The QStyle class specifies the look and feel of a GUI.
A large number of GUI elements are common to many widgets. The
QStyle class allows the look of these elements to be modified
across all widgets that use the QStyle functions. It also
provides two feel options: Motif and Windows.
Although it is not possible to fully enumerate the look of graphic elements
and the feel of widgets in a GUI, QStyle provides a considerable
amount of control and customisability.
In Qt 1.x the look and feel option for widgets was specified by a
single value - the GUIStyle. Starting with Qt 2.0, this notion has
been expanded to allow the look to be specified by virtual drawing
functions.
Derived classes may reimplement some or all of the drawing functions
to modify the look of all widgets that use those functions.
Languages written from right to left (such as hebrew and arabic)
usually also mirror the whole layout of widgets. If you design a
style, you should take special care when drawing asymmetric elements
to make sure that they also look correct in a mirrored layout. You can
start your application with -reverse to check the mirrored layout.
Also notice, that for a reversed layout, the light usually comes
from top right instead of top left.
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 function in the
QStyle API states whether the function expects/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.
Member Type Documentation
QStyle::ComplexControl
This enum represents a ComplexControl. A ComplexControl is different from a
ControlElement. ComplexControls have different behavior depending upon where
the user clicks or which keys are pressed.
- QStyle::CC_SpinWidget
- QStyle::CC_ComboBox
- QStyle::CC_ScrollBar
- QStyle::CC_Slider
- QStyle::CC_ToolButton
- QStyle::CC_TitleBar
- QStyle::CC_ListView
See also SubControl and drawComplexControl().
QStyle::ContentsType
This enum represents a ContentsType. It is used to calculate sizes for the contents
of various widgets.
- QStyle::CT_PushButton
- QStyle::CT_CheckBox
- QStyle::CT_RadioButton
- QStyle::CT_ToolButton
- QStyle::CT_ComboBox
- QStyle::CT_Splitter
- QStyle::CT_DockWindow
- QStyle::CT_ProgressBar
- QStyle::CT_PopupMenuItem
See also sizeFromContents().
QStyle::ControlElement
This enum represents a ControlElement. A ControlElement is part of a widget that
does some action or display information to the user.
- QStyle::CE_PushButton - the bevel and default indicator of a QPushButton.
- QStyle::CE_PushButtonLabel - the label ( iconset with text or pixmap ) of a QPushButton.
- QStyle::CE_CheckBox - the indicator of a QCheckBox.
- QStyle::CE_CheckBoxLabel - the label ( text or pixmap ) of a QCheckBox.
- QStyle::CE_RadioButton - the indicator of a QRadioButton.
- 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 with in a QTab.
- 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_PopupMenuItem - a menu item of a QPopupMenu.
- QStyle::CE_MenuBarItem - a menu item of a QMenuBar.
See also drawControl().
QStyle::ControlElementFlags
This enum represents flags for drawing ControlElements. Not all controls use all
of these flags. Note that these flags can have different meaning for different
controls. For an explanation of the relationship of various controls and flags,
as well as the different meanings of the flags, see the Style overview.
- QStyle::CStyle_Default
- QStyle::CStyle_Selected
- QStyle::CStyle_HasFocus
- QStyle::CStyle_Active
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 pushbutton labels and the frame.
- QStyle::PM_ButtonDefaultIndicator - width of the default-button indicator frame.
- QStyle::PM_MenuButtonIndicator - width of the menu button indicator for a 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_MaximumDragDistance - Some feels require the scrollbar 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 scrollbar and the height of a
horizontal scrollbar.
- 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 horiztonal 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_MenuBarFrameWidth - frame width of a menubar.
- 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 heigth.
- 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_ProgressBarChunkWidth - width of a chunk in a progress bar indicator.
- QStyle::PM_SplitterWidth - width of a splitter.
- 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.
See also pixelMetric().
QStyle::PrimitiveElement
This enum represents a style PrimitiveElement. A PrimitiveElement is
a common GUI element, such as a checkbox indicator or pushbutton bevel.
- QStyle::PE_ButtonCommand - button that performs an action/command, for example: a
push button.
- QStyle::PE_ButtonBevel - general purpose button bevel.
- QStyle::PE_ButtonTool - tool button, for example: a button in a toolbar.
- QStyle::PE_ButtonDropDown - drop down button, for example: a tool button that displays
a popup menu.
- QStyle::PE_FocusRect - general purpose focus indicator.
- QStyle::PE_ArrowUp - up arrow.
- QStyle::PE_ArrowDown - down arrow.
- QStyle::PE_ArrowRight - right arrow.
- QStyle::PE_ArrowLeft - left arrow.
- QStyle::PE_SpinWidgetUp - up symbol for a spin widget.
- QStyle::PE_SpinWidgetDown - down symbol for a spin widget.
- QStyle::PE_SpinWidgetPlus - increase symbol for a spin widget.
- QStyle::PE_SpinWidgetMinus - decrease symbol for a spin widget.
For more explanation of a spin widget, see the QSpinBox documentation.
- QStyle::PE_Indicator - on/off indicator, for example: a check box.
- QStyle::PE_IndicatorMask - bitmap mask for an indicator.
- QStyle::PE_ExclusiveIndicator - exclusive on/off indicator, for example: a radio button.
- QStyle::PE_ExclusiveIndicatorMask - bitmap mask for an exclusive indicator.
- QStyle::PE_DockWindowHandle - tear off handle for dock windows and toolbars.
- QStyle::PE_DockWindowSeparator - item separator for dock window and toolbar contents.
- QStyle::PE_DockWindowResizeHandle - resize handle for dock windows.
- QStyle::PE_Splitter - splitter handle.
- QStyle::PE_Panel - general purpose panel frame.
- QStyle::PE_PanelPopup - panel frame for popup windows/menus.
- QStyle::PE_PanelMenuBar - panel frame for menu bars.
- QStyle::PE_PanelDockWindow - panel frame for dock windows and toolbars.
For more information on dock windows, see the QDockWindow documentation.
- QStyle::PE_TabBarBase - area below tabs in a tab widget.
- QStyle::PO_HeaderSection - section of a list/table header.
- QStyle::PO_HeaderArrow - arrow used to indicate sorting on a list/table
header
- QStyle::PO_StatusBarSection - section of a status bar.
- QStyle::PE_GroupBoxFrame - frame around a group box.
- QStyle::PE_Separator - general purpose separator.
- QStyle::PE_SizeGrip - window resize handle.
- QStyle::PE_CheckMark - general purpose check mark.
- QStyle::PE_ScrollBarAddLine - scrollbar line increase indicator (ie. scroll down).
- QStyle::PE_ScrollBarSubLine - scrollbar line decrease indicator (ie. scroll up).
- QStyle::PE_ScrollBarAddPage - scolllbar page increase indicator (ie. page down).
- QStyle::PE_ScrollBarSubPage - scrollbar page decrease indicator (ie. page up).
- QStyle::PE_ScrollBarSlider - scrollbar slider
- QStyle::PE_ScrollBarFirst - scrollbar first line indicator (ie. home).
- QStyle::PE_ScrollBarLast - scrollbar last line indicator (ie. end).
- QStyle::PO_ProgressBarChunk - section of a progress bar indicator.
See also drawPrimitive().
QStyle::PrimitiveElementFlags
This enum represents flags for drawing PrimitiveElements. Not all primitives
use all of these flags. Note that these flags can have different meaning for
different primitives. For an explanation of the relationship of various primitives
and flags, as well as the different meanings of the flags, see the Style overview.
- QStyle::PStyle_Default
- QStyle::PStyle_Enabled
- QStyle::PStyle_Raised
- QStyle::PStyle_Sunken
- QStyle::PStyle_Off
- QStyle::PStyle_NoChange
- QStyle::PStyle_On
- QStyle::PStyle_Down
- QStyle::PStyle_Horizontal
- QStyle::PStyle_Vertical
- QStyle::PStyle_HasFocus
- QStyle::PStyle_Top
- QStyle::PStyle_Bottom
- QStyle::PStyle_FocusAtBorder
- QStyle::PStyle_AutoRaise
- QStyle::PStyle_MouseOver
- QStyle::PStyle_Up
See also drawPrimitive().
QStyle::StyleHint
This enum represents a StyleHint. A StyleHint is a general Look and/or Feel hint.
- QStyle::SH_ScrollBar_BackgroundMode - the background mode for a QScrollBar. Possible
values are any in the BackgroundMode enum.
- QStyle::SH_ScrollBar_MiddleClickAbsolutePosition - a boolean value. If TRUE, middle
clicking on a scrollbar causes the slider to jump to that position. If FALSE,
the click is ignored.
- QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl - a boolean value. If TRUE, when
clicking a scrollbar SubControl, holding the mouse button down and moving the
pointer outside the SubControl, the scrollbar 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.
See also styleHint().
QStyle::StylePixmap
This enum represents a StylePixmap. A StylePixmap is a pixmap that can follow some
existing GUI style or guideline.
- QStyle::SP_TitleBarMinButton - minimize button on titlebars. For example, in a
QWorkspace.
- QStyle::SP_TitleBarMaxButton - maximize button on titlebars.
- QStyle::SP_TitleBarCloseButton - close button on titlebars.
- QStyle::SP_TitleBarNormalButton - normal (restore) button on titlebars.
- QStyle::SP_TitleBarShadeButton - shade button on titlebars.
- QStyle::SP_TitleBarUnshadeButton - unshade button on titlebars.
- QStyle::SP_DockWindowCloseButton - close button on dock windows. See also QDockWindow.
See also stylePixmap().
QStyle::SubControl
This enum represents a SubControl within a ComplexControl.
- QStyle::SC_None - special value that matches no other SubControl.
- QStyle::SC_ScrollBarAddLine - scrollbar add line (ie. down/right arrow).
- QStyle::SC_ScrollBarSubLine - scrollbar sub line (ie. up/left arrow).
- QStyle::SC_ScrollBarAddPage - scrollbar add page (ie. page down).
- QStyle::SC_ScrollBarSubPage - scrollbar sub page (ie. page up).
- QStyle::SC_ScrollBarFirst - scrollbar first line (ie. home).
- QStyle::SC_ScrollBarLast - scrollbar last line (ie. end).
- QStyle::SC_ScrollBarSlider - scrollbar slider handle.
- QStyle::SC_ScrollBarGroove - special subcontrol which contains the area in which the
slider handle may move.
- QStyle::SC_SpinWidgetUp - spinwidget up/increase.
- QStyle::SC_SpinWidgetDown - spinwidget down/decrease.
- QStyle::SC_SpinWidgetFrame - spinwidget frame.
- QStyle::SC_SpinWidgetEditField - spinwidget edit field.
- QStyle::SC_SpinWidgetButtonField - spinwidget button field.
- QStyle::SC_ComboBoxEditField - combobox edit field.
- QStyle::SC_ComboBoxArrow - combobox arrow
- QStyle::SC_SliderGroove - special subcontrol 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.
- QStyle::SC_ToolButtonMenu - subcontrol for opening a popup menu in a tool button.
- QStyle::SC_TitleBarSysMenu - system menu button (ie. 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_ListView - ???
- QStyle::SC_ListViewBranch - ???
- QStyle::SC_ListViewExpand - expand item (ie. show/hide child items).
- QStyle::SC_All - special value that matches all SubControls.
See also ComplexControl.
QStyle::SubRect
This enum represents a sub-area of a widget. Style implementations would use these
areas to draw the different parts of a widget.
- QStyle::SR_PushButtonContents - area containing the label (iconset 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 (eg. 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.
See also subRect().
Member Function Documentation
QStyle::~QStyle () [virtual]
Destroys the style and frees all allocated resources.
void QStyle::drawComplexControl ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, CFlags flags = CStyle_Default, SCFlags sub = SC_All, SCFlags subActive = SC_None, void ** data = 0 ) const [virtual]
Draws the ComplexControl control using the painter p in the area r. Colors
are used from the color group cg. The sub argument specifies which SubControls
to draw. Multiple SubControls can be OR'ed together. The subActive argument
specifies which SubControl to draw as active.
The rect r should be in logical coordinates. Reimplementations of this function
should use visualRect() to change the logical corrdinates into screen coordinates
when using drawPrimitive() and drawControl().
The flags argument is used to control how the ComplexControl is drawn. Multiple
flags can OR'ed together.
The widget argument is a pointe rto a QWidget or one of its subclasses. The widget
can be cast to the appropriate type based on the value of control. The data
argument can be used to pass extra information required when drawing the
ComplexControl. Note that data can be zero even for ComplexControls that make
use of the extra data. See the table below for the appropriate widget and
data casts:
ComplexControl |
Widget Cast |
Data |
Data Cast |
Notes |
CC_SpinWidget |
const QSpinWidget * |
unused |
|
|
CC_ComboBox |
const QComboBox * |
unused |
|
|
CC_ScrollBar |
const QScrollBar * |
data[0] |
int * |
position in pixels for the start of the slider handle. |
CC_Slider |
const QSlider * |
data[0] |
int * |
position in pixel for the start of the slider handle. |
CC_ToolButton |
const QToolButton * |
data[0] |
bool * |
when the tool button has auto-raise enabled, this bool is TRUE when
the mouse is over the tool button, FALSE otherwise. |
|
|
data[1] |
bool * |
this bool TRUE when the tool button only contains an arrow, FALSE
otherwise. |
|
|
data[2] |
ArrowType * |
when the tool button only contains an arrow, this is the arrow
type. |
CC_TitleBar |
const QWidget * |
unused |
|
|
CC_ListView |
const QListView * |
data[0] |
QListViewItem * |
pointer to the item that needs branches drawn |
See also ComplexControl and SubControl.
void QStyle::drawComplexControlMask ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, void ** data = 0 ) const [virtual]
Draw a bitmask for the ComplexControl control using the painter p in the
area r. See the documentation for drawComplexControl() for an explanation on the
use of the widget and data arguments.
The rect r should be in logical coordinates. Reimplementations of this function
should use visualRect() to change the logical corrdinates into screen coordinates
when using drawPrimitive() and drawControl().
See also drawComplexControl and ComplexControl.
void QStyle::drawControl ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, CFlags how = CStyle_Default, void ** data = 0 ) const [virtual]
Draws the ControlElement element using the painter p in the area r. Colors
are used from the color group cg.
The rect r should be in screen coordinates.
The how argument is used to control how the ControlElement is drawn. Multiple
flags can be OR'ed together.
The widget argument is a pointer to a QWidget or one of its subclasses. The
widget can be cast to the appropriate type based on the value of element. The
data argument can be used to pass extra information required when drawing the
ControlElement. Note that data can be zero even for ControlElements that make
use of the extra data. See the table below for the appropriate widget and
data casts:
ControlElement |
Widget Cast |
Data |
Data Cast |
Notes |
CE_PushButton |
const QPushButton * |
unused |
|
|
CE_PushButtonLabel |
const QPushButton * |
unused |
|
|
CE_CheckBox |
const QCheckBox * |
unused |
|
|
CE_CheckboxLabel |
const QCheckBox * |
unused |
|
|
CE_RadioButton |
const QRadioButton * |
unused |
|
|
CE_RadioButtonLabel |
const QRadioButton * |
unused |
|
|
CE_TabBarTab |
const QTabBar * |
unused |
|
|
CE_TabBarLabel |
const QTabBar * |
data[0] |
QTab * |
pointer to the QTab being drawn. |
CE_ProgressBarGroove |
const QProgressBar * |
unused |
|
|
CE_ProgressBarContents |
const QProgressBar * |
unused |
|
|
CE_ProgressBarLabel |
const QProgressBar * |
unused |
|
|
CE_PopupMenuItem |
const QPopupMenu * |
data[0] |
QMenuItem * |
pointer to the menu item being drawn. |
|
|
data[1] |
int * |
width of the tab column where key accelerators are drawn. |
|
|
data[2] |
int * |
maximum width of the check column where checkmarks and iconsets
are drawn. |
CE_MenuBarItem |
const QMenuBar * |
data[0] |
QMenuItem * |
pointer to the menu item being drawn. |
See also ControlElement and ControlElementFlags.
void QStyle::drawControlMask ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, void ** data = 0 ) const [virtual]
Draw a bitmask for the ControlElement element using the painter p in the
area \r. See the documentation for drawControl() for an explanation on use
of the widget and data arguments.
The rect r should be in screen coordinates.
See also drawControl() and ControlElement.
void QStyle::drawItem ( QPainter * p, const QRect & r, int flags, const QColorGroup & g, bool enabled, const QPixmap * pixmap, const QString & text, int len = -1, const QColor * penColor = 0 ) const [virtual]
Draws the text or pixmap in rectangle r using painter p
and color group g. 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 according to the alignment flags (see
Qt::AlignmentFlags).
void QStyle::drawPrimitive ( PrimitiveElement op, QPainter * p, const QRect & r, const QColorGroup & cg, PFlags flags = PStyle_Default, void ** data = 0 ) const [virtual]
Draws the style PrimitiveElement op using the painter p in the
area r. Colors are used from the color group cg.
The rect r should be in screen coordinates.
The flags argument is used to control how the PrimitiveElement is drawn.
Multiple flags can be OR'ed together.
For example, a pressed button would be drawn with the flags PStyle_Enabled and
PStyle_Down.
The data argument can be used to control how various PrimitiveElements are drawn.
Note that data can be zero even for PrimitiveElementss that make use of extra
data. When data is non-zero, the data is used as follows:
PrimitiveElement |
Data |
Data Cast |
Notes |
PE_FocusRect |
data[0] |
const QColor * |
pointer to the background color the on which focus rect is
being drawn. |
PE_Panel |
data[0] |
int * |
line width for drawing the panel. |
PE_PanelPopup |
data[0] |
int * |
line width for drawing the panel. |
PE_PanelMenuBar |
data[0] |
int * |
line width for drawing the panel. |
PE_PanelDockWindow |
data[0] |
int * |
line width for drawing the panel. |
PE_GroupBoxFrame |
data[0] |
int * |
frame shape for the group box. See the documentation for QFrame
for more details. |
|
data[1] |
int * |
frame shadow for the group box. |
|
data[2] |
int * |
line width for the group box. |
|
data[3] |
int * |
mid-line width for the group box. |
For all other PrimitiveElements, data is unused.
See also PrimitiveElement and PrimitiveElementFlags.
GUIStyle QStyle::guiStyle () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
Returns an indicator to the additional "feel" component of a
style. Current supported values are Qt::WindowsStyle and Qt::MotifStyle.
QRect QStyle::itemRect ( QPainter * p, const QRect & r, int flags, bool enabled, const QPixmap * pixmap, const QString & text, int len = -1 ) const [virtual]
Returns the appropriate area (see below) within rectangle r in
which to draw the text or pixmap using painter p. 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
according to the alignment flags (see Qt::AlignmentFlags).
If r is larger than the area needed to render the text the rectangle that is returned will be offset within r in
accordance with the alignment flags. For example if flags is
AlignVCenter | AlignHCenter the returned rectangle will be
centered within r. If r is smaller than the area needed the
rectangle that is returned will be larger than r (the
smallest rectangle large enough to render the text or pixmap).
QStyle::operator GUIStyle () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
bool QStyle::operator!= ( GUIStyle s ) const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
bool QStyle::operator== ( GUIStyle s ) const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
int QStyle::pixelMetric ( PixelMetric metric, const QWidget * widget = 0 ) const [virtual]
Returns the pixel metric for metric. The widget argument is a pointer to
a QWidget of one of its subclasses. The widget can be cast to the appropriate type
based on the value of metric. Note that widget can be zero even for
PixelMetrics that make use of widget. See the table below for the appropriate
widget casts:
PixelMetric |
Widget Cast |
PM_SliderControlThickness |
const QSlider * |
PM_SliderLength |
const QSlider * |
PM_SliderTickmarkOffset |
const QSlider * |
PM_SliderSpaceAvailable |
const QSlider * |
PM_TabBarTabOverlap |
const QTabBar * |
PM_TabBarTabHSpace |
const QTabBar * |
PM_TabBarTabVSpace |
const QTabBar * |
PM_TabBarBaseHeight |
const QTabBar * |
PM_TabBarBaseOverlap |
const QTabBar * |
See also PixelMetric.
void QStyle::polish ( QWidget * ) [virtual]
Initializes the appearance of a widget.
This function is called for every widget at some point after it has
been fully created but just before it is shown 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!
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 will be expected to work
reasonably with all current and future widgets.
See also unPolish(QWidget*).
Examples: themes/metal.cpp and themes/wood.cpp.
void QStyle::polish ( QApplication * ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Late initialization of the QApplication object.
See also unPolish(QApplication*).
void QStyle::polish ( QPalette & ) [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 according to these
requirements.
See also QPalette and QApplication::setPalette().
void QStyle::polishPopupMenu ( QPopupMenu * ) [virtual]
Polishes the popup menu according to the GUI style. This usually means
setting the mouse tracking (QPopupMenu::setMouseTracking()) and whether
the menu is checkable by default (QPopupMenu::setCheckable()).
SubControl QStyle::querySubControl ( ComplexControl control, const QWidget * widget, const QPoint & pos, void ** data = 0 ) const [virtual]
Returns the SubControl for widget at the point pos. The widget argument
is a pointer to a QWidget or one of its subclasses,. The widget can be case to the
appropriate type based on the value of control. The data argument can be
used to pass extra information required when drawing the ComplexControl. Note
that data can be zero even for ComplexControls that make use of the extra data.
See the documentation for drawComplexControl() for an explanation of the widget
and data arguments.
Note that pos is passed 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 and querySubControlMetrics().
QRect QStyle::querySubControlMetrics ( ComplexControl control, const QWidget * widget, SubControl subcontrol, void ** data = 0 ) const [virtual]
Returns the rect for the SubControl subcontrol for widget in logical coordinates.
The widget argument is a pointer to a QWidget or one of its subclasses. The
widget can be cast to the appropriate type based on the value of control.
The data argument can be used to pass extra information required when drawing the
ComplexControl. Note that data can be zero even for ComplexControls that make
use of the extra data. See the documentation for drawComplexControl() for an
explanation of the widget and data arguments.
See also drawComplexControl(), ComplexControl and SubControl.
QSize QStyle::sizeFromContents ( ContentsType contents, const QWidget * widget, const QSize & contentsSize, void ** data = 0 ) const [virtual]
Returns the size of widget based on the contents size contentsSize.
The widget argument is a pointer to a QWidget or one of its subclasses. The
widget can be cast to the appropriate type based on the value of contents. The
data argument can be used to pass extra information required when calculating the
size. Note that data can be zero even for ContentsTypes that make use of the
extra data. See the table below for the appropriate widget and data casts:
ContentsType |
Widget Cast |
Data |
Data Cast |
Notes |
CT_PushButton |
const QPushButton * |
unused |
|
|
CT_CheckBox |
const QCheckBox * |
unused |
|
|
CT_RadioButton |
const QRadioButton * |
unused |
|
|
CT_ToolButton |
const QToolButton * |
unused |
|
|
CT_ComboBox |
const QComboBox * |
unused |
|
|
CT_Splitter |
const QSplitter * |
unused |
|
|
CT_DockWindow |
const QDockWindow * |
unused |
|
|
CT_ProgressBar |
const QProgressBar * |
unused |
|
|
CT_PopupMenuItem |
const QPopupMenu * |
data[0] |
QMenuItem * |
pointer to the menu item to use when calculating the size |
See also ContentsType.
int QStyle::styleHint ( StyleHint stylehint, const QWidget * widget = 0, void *** returnData = 0 ) const [virtual]
Returns the style hint stylehint for widget. Currently, widget and returnData are unused, and are provided only for future development considerations.
For explanation on the return values of this function, see the StyleHint documentation.
See also StyleHint.
QPixmap QStyle::stylePixmap ( StylePixmap stylepixmap, const QWidget * widget = 0, void ** data = 0 ) const [virtual]
Returns a pixmap for stylepixmap.
The data argument can be used to pass extra information required when drawing the
ControlElement. Note that data can be zero even for StylePixmaps that make
use of the extra data. Currently, the data argument is unused.
The widget argument is a pointer to a QWidget or one of its subclasses. The
widget can be cast to the appropriate type based on the value of stylepixmap.
See the table below for the appropriate widget casts:
StylePixmap |
Widget Cast |
SP_TitleBarMinButton |
const QWidget * |
SP_TitleBarMaxButton |
const QWidget * |
SP_TitleBarCloseButton |
const QWidget * |
SP_TitleBarNormalButton |
const QWidget * |
SP_TitleBarShadeButton |
const QWidget * |
SP_TitleBarUnshadeButton |
const QWidget * |
SP_DockWindowCloseButton |
const QDockWindow * |
See also StylePixmap.
QRect QStyle::subRect ( SubRect subrect, const QWidget * widget ) const [virtual]
Returns the sub-area subrect for widget in logical coordinates.
The widget argument is a pointer to a QWidget or one of its subclasses. The
widget can be cast to the appropriate type based on the value of subrect. See
the table below for the appropriate widget casts:
SubRect |
Widget Cast |
SR_PushButtonContents |
const QPushButton * |
SR_PushButtonFocusRect |
const QPushButton * |
SR_CheckBoxIndicator |
const QCheckBox * |
SR_CheckBoxContents |
const QCheckBox * |
SR_CheckBoxFocusRect |
const QCheckBox * |
SR_RadioButtonIndicator |
const QRadioButton * |
SR_RadioButtonContents |
const QRadioButton * |
SR_RadioButtonFocusRect |
const QRadioButton * |
SR_ComboBoxFocusRect |
const QComboBox * |
SR_DockWindowHandleRect |
const QWidget * |
SR_ProgressBarGroove |
const QProgressBar * |
SR_ProgressBarContents |
const QProgressBar * |
SR_ProgressBarLabel |
const QProgressBar * |
NOTE: The tear-off handle (SR_DockWindowHandleRect) for QDockWindow is a private
class. You can gain access to the QDockWindow by using the QWidget::parentWidget()
function. For example:
if (! widget->parentWidget())
return;
const QDockWindow *dw = (const QDockWindow *) widget->parentWidget();
See also SubRect.
void QStyle::unPolish ( QWidget * ) [virtual]
Undoes the initialization of a 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(QWidget*).
Examples: themes/metal.cpp and themes/wood.cpp.
void QStyle::unPolish ( QApplication * ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Undoes the application polish.
See also polish(QApplication*).
QRect QStyle::visualRect ( const QRect & logical, const QWidget * w ) [static]
Returns the rect logical in screen coordinates. The bounding
rect for widget w is used to perform the translation. This
function is provided to aid style implementors in supporting
right-to-left mode.
See also QApplication::reverseLayout().
QRect QStyle::visualRect ( const QRect & logical, const QRect & bounding ) [static]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the rect logical in screen coordinates. The rect bounding
is used to perform the translation. This function is provided to aid style
implementors in supporting right-to-left mode.
See also QApplication::reverseLayout().
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit,
copyright © 1995-2001
Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks
| Qt version 3.0.0-beta2
|