📄 qstyle.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qstyle.cpp:246 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QStyle Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QStyle Class Reference</h1><p>The QStyle class specifies the look and feel of a GUI.<a href="#details">More...</a><p><tt>#include <<a href="qstyle-h.html">qstyle.h</a>></tt><p>Inherits <a href="qobject.html">QObject</a>.<p>Inherited by <a href="qcommonstyle.html">QCommonStyle</a>.<p><a href="qstyle-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QStyle"><b>QStyle</b></a> ()</div></li><li><div class=fn>virtual <a href="#~QStyle"><b>~QStyle</b></a> ()</div></li><li><div class=fn>virtual void <a href="#polish"><b>polish</b></a> ( QWidget * )</div></li><li><div class=fn>virtual void <a href="#unPolish"><b>unPolish</b></a> ( QWidget * )</div></li><li><div class=fn>virtual void <a href="#polish-2"><b>polish</b></a> ( QApplication * )</div></li><li><div class=fn>virtual void <a href="#unPolish-2"><b>unPolish</b></a> ( QApplication * )</div></li><li><div class=fn>virtual void <a href="#polish-3"><b>polish</b></a> ( QPalette & )</div></li><li><div class=fn>virtual void <a href="#polishPopupMenu"><b>polishPopupMenu</b></a> ( QPopupMenu * ) = 0</div></li><li><div class=fn>virtual QRect <a href="#itemRect"><b>itemRect</b></a> ( QPainter * p, const QRect & r, int flags, bool enabled, const QPixmap * pixmap, const QString & text, int len = -1 ) const</div></li><li><div class=fn>virtual void <a href="#drawItem"><b>drawItem</b></a> ( 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</div></li><li><div class=fn>enum <a href="#PrimitiveElement-enum"><b>PrimitiveElement</b></a> { PE_ButtonCommand, PE_ButtonDefault, 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, PE_PanelLineEdit, PE_PanelTabWidget, PE_WindowFrame, PE_CustomBase = 0xf000000 }</div></li><li><div class=fn>enum <a href="#StyleFlags-enum"><b>StyleFlags</b></a> { Style_Default = 0x00000000, Style_Enabled = 0x00000001, Style_Raised = 0x00000002, Style_Sunken = 0x00000004, Style_Off = 0x00000008, Style_NoChange = 0x00000010, Style_On = 0x00000020, Style_Down = 0x00000040, Style_Horizontal = 0x00000080, Style_HasFocus = 0x00000100, Style_Top = 0x00000200, Style_Bottom = 0x00000400, Style_FocusAtBorder = 0x00000800, Style_AutoRaise = 0x00001000, Style_MouseOver = 0x00002000, Style_Up = 0x00004000, Style_Selected = 0x00008000, Style_Active = 0x00010000, Style_ButtonDefault = 0x00020000 }</div></li><li><div class=fn>virtual void <a href="#drawPrimitive"><b>drawPrimitive</b></a> ( PrimitiveElement pe, QPainter * p, const QRect & r, const QColorGroup & cg, SFlags flags = Style_Default, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>enum <a href="#ControlElement-enum"><b>ControlElement</b></a> { 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, CE_ToolButtonLabel, CE_PopupMenuScroller, CE_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual void <a href="#drawControl"><b>drawControl</b></a> ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, SFlags how = Style_Default, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>virtual void <a href="#drawControlMask"><b>drawControlMask</b></a> ( ControlElement element, QPainter * p, const QWidget * widget, const QRect & r, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>enum <a href="#SubRect-enum"><b>SubRect</b></a> { 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, SR_ToolButtonContents, SR_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual QRect <a href="#subRect"><b>subRect</b></a> ( SubRect subrect, const QWidget * widget ) const = 0</div></li><li><div class=fn>enum <a href="#ComplexControl-enum"><b>ComplexControl</b></a> { CC_SpinWidget, CC_ComboBox, CC_ScrollBar, CC_Slider, CC_ToolButton, CC_TitleBar, CC_ListView, CC_CustomBase = 0xf0000000 }</div></li><li><div class=fn>enum <a href="#SubControl-enum"><b>SubControl</b></a> { 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_ComboBoxFrame = 0x00000001, SC_ComboBoxEditField = 0x00000002, SC_ComboBoxArrow = 0x00000004, SC_SliderGroove = 0x00000001, SC_SliderHandle = 0x00000002, SC_SliderTickmarks = 0x00000004, SC_ToolButton = 0x00000001, SC_ToolButtonMenu = 0x00000002, SC_TitleBarLabel = 0x00000001, SC_TitleBarSysMenu = 0x00000002, SC_TitleBarMinButton = 0x00000004, SC_TitleBarMaxButton = 0x00000008, SC_TitleBarCloseButton = 0x00000010, SC_TitleBarNormalButton = 0x00000020, SC_TitleBarShadeButton = 0x00000040, SC_TitleBarUnshadeButton = 0x00000080, SC_ListView = 0x00000001, SC_ListViewBranch = 0x00000002, SC_ListViewExpand = 0x00000004, SC_All = 0xffffffff }</div></li><li><div class=fn>virtual void <a href="#drawComplexControl"><b>drawComplexControl</b></a> ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, const QColorGroup & cg, SFlags how = Style_Default, SCFlags sub = SC_All, SCFlags subActive = SC_None, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>virtual void <a href="#drawComplexControlMask"><b>drawComplexControlMask</b></a> ( ComplexControl control, QPainter * p, const QWidget * widget, const QRect & r, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>virtual QRect <a href="#querySubControlMetrics"><b>querySubControlMetrics</b></a> ( ComplexControl control, const QWidget * widget, SubControl subcontrol, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>virtual SubControl <a href="#querySubControl"><b>querySubControl</b></a> ( ComplexControl control, const QWidget * widget, const QPoint & pos, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>enum <a href="#PixelMetric-enum"><b>PixelMetric</b></a> { PM_ButtonMargin, PM_ButtonDefaultIndicator, PM_MenuButtonIndicator, PM_ButtonShiftHorizontal, PM_ButtonShiftVertical, PM_DefaultFrameWidth, PM_SpinBoxFrameWidth, PM_MaximumDragDistance, PM_ScrollBarExtent, PM_ScrollBarSliderMin, 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_TitleBarHeight, PM_IndicatorWidth, PM_IndicatorHeight, PM_ExclusiveIndicatorWidth, PM_ExclusiveIndicatorHeight, PM_PopupMenuScrollerHeight, PM_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual int <a href="#pixelMetric"><b>pixelMetric</b></a> ( PixelMetric metric, const QWidget * widget = 0 ) const = 0</div></li><li><div class=fn>enum <a href="#ContentsType-enum"><b>ContentsType</b></a> { CT_PushButton, CT_CheckBox, CT_RadioButton, CT_ToolButton, CT_ComboBox, CT_Splitter, CT_DockWindow, CT_ProgressBar, CT_PopupMenuItem, CT_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual QSize <a href="#sizeFromContents"><b>sizeFromContents</b></a> ( ContentsType contents, const QWidget * widget, const QSize & contentsSize, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>enum <a href="#StyleHint-enum"><b>StyleHint</b></a> { SH_EtchDisabledText, SH_GUIStyle, SH_ScrollBar_BackgroundMode, SH_ScrollBar_MiddleClickAbsolutePosition, SH_ScrollBar_ScrollWhenPointerLeavesControl, SH_TabBar_SelectMouseType, SH_TabBar_Alignment, SH_Header_ArrowAlignment, SH_Slider_SnapToValue, SH_Slider_SloppyKeyEvents, SH_ProgressDialog_CenterCancelButton, SH_ProgressDialog_TextLabelAlignment, SH_PrintDialog_RightAlignButtons, SH_MainWindow_SpaceBelowMenuBar, SH_FontDialog_SelectAssociatedText, SH_PopupMenu_AllowActiveAndDisabled, SH_PopupMenu_SpaceActivatesItem, SH_PopupMenu_SubMenuPopupDelay, SH_ScrollView_FrameOnlyAroundContents, SH_MenuBar_AltKeyNavigation, SH_ComboBox_ListMouseTracking, SH_PopupMenu_MouseTracking, SH_MenuBar_MouseTracking, SH_ItemView_ChangeHighlightOnFocus, SH_Widget_ShareActivation, SH_Workspace_FillSpaceOnMaximize, SH_ComboBox_Popup, SH_TitleBar_NoBorder, SH_ScrollBar_StopMouseOverSlider, SH_BlinkCursorWhenTextSelected, SH_RichText_FullWidthSelection, SH_PopupMenu_Scrollable, SH_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual int <a href="#styleHint"><b>styleHint</b></a> ( StyleHint stylehint, const QWidget * widget = 0, const QStyleOption & opt = QStyleOption::Default, QStyleHintReturn * returnData = 0 ) const = 0</div></li><li><div class=fn>enum <a href="#StylePixmap-enum"><b>StylePixmap</b></a> { SP_TitleBarMinButton, SP_TitleBarMaxButton, SP_TitleBarCloseButton, SP_TitleBarNormalButton, SP_TitleBarShadeButton, SP_TitleBarUnshadeButton, SP_DockWindowCloseButton, SP_MessageBoxInformation, SP_MessageBoxWarning, SP_MessageBoxCritical, SP_CustomBase = 0xf0000000 }</div></li><li><div class=fn>virtual QPixmap <a href="#stylePixmap"><b>stylePixmap</b></a> ( StylePixmap stylepixmap, const QWidget * widget = 0, const QStyleOption & opt = QStyleOption::Default ) const = 0</div></li><li><div class=fn>int defaultFrameWidth () const <em>(obsolete)</em></div></li><li><div class=fn>void tabbarMetrics ( const QWidget * t, int & hf, int & vf, int & ov ) const <em>(obsolete)</em></div></li><li><div class=fn>QSize scrollBarExtent () const <em>(obsolete)</em></div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>QRect <a href="#visualRect"><b>visualRect</b></a> ( const QRect & logical, const QWidget * w )</div></li><li><div class=fn>QRect <a href="#visualRect-2"><b>visualRect</b></a> ( const QRect & logical, const QRect & bounding )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QStyle class specifies the look and feel of a GUI.<p> A large number of GUI elements are common to many widgets. TheQStyle class allows the look of these elements to be modifiedacross all widgets that use the QStyle functions. It alsoprovides two feel options: Motif and Windows.<p> Although it is not possible to fully enumerate the look ofgraphical elements and the feel of widgets in a GUI, QStyleprovides a considerable amount of control and customisability.<p> In Qt 1.x the look and feel option for widgets was specified by asingle value: the GUIStyle. Starting with Qt 2.0, this notion wasexpanded to allow the look to be specified by virtual drawingfunctions.<p> Derived classes may reimplement some or all of the drawingfunctions to modify the look of all widgets that use thosefunctions.<p> Languages written from right to left (such as Arabic and Hebrew)usually also mirror the whole layout of widgets. If you design astyle, you should take special care when drawing asymmetricelements to make sure that they also look correct in a mirroredlayout. You can start your application with <tt>-reverse</tt> to checkthe mirrored layout. Also notice, that for a reversed layout, thelight usually comes from top right instead of top left.<p> The actual reverse layout is performed automatically whenpossible. However, for the sake of flexibility, the translationcannot be performed everywhere. The documentation for eachfunction in the QStyle API states whether the functionexpects/returns logical or screen coordinates. Using logicalcoordinates (in ComplexControls, for example) provides greatflexibility in controlling the look of a widget. Use <a href="#visualRect">visualRect</a>()when necessary to translate logical coordinates into screencoordinates for drawing.<p> In Qt versions prior to 3.0, if you wanted a low level route intochanging the appearance of a widget, you would reimplement<a href="#polish">polish</a>(). With the new 3.0 style engine the recommended approachis to reimplement the draw functions, for example <a href="#drawItem">drawItem</a>(),<a href="#drawPrimitive">drawPrimitive</a>(), <a href="#drawControl">drawControl</a>(), <a href="#drawControlMask">drawControlMask</a>(),<a href="#drawComplexControl">drawComplexControl</a>() and <a href="#drawComplexControlMask">drawComplexControlMask</a>(). Each of thesefunctions is called with a range of parameters that provideinformation that you can use to determine how to draw them, e.g.style flags, rectangle, color group, etc.<p> For information on changing elements of an existing style orcreating your own style see the <a href="customstyles.html">Style overview</a>.<p> Styles can also be created as <a href="plugins-howto.html">plugins</a>.<p>See also <a href="appearance.html">Widget Appearance and Style</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="ComplexControl-enum"></a>QStyle::ComplexControl</h3><p> This enum represents a ComplexControl. ComplexControls havedifferent behaviour depending upon where the user clicks on themor which keys are pressed.<ul><li><tt>QStyle::CC_SpinWidget</tt><li><tt>QStyle::CC_ComboBox</tt><li><tt>QStyle::CC_ScrollBar</tt><li><tt>QStyle::CC_Slider</tt><li><tt>QStyle::CC_ToolButton</tt><li><tt>QStyle::CC_TitleBar</tt><li><tt>QStyle::CC_ListView</tt></ul><p> <ul><li><tt>QStyle::CC_CustomBase</tt> - base value for custom ControlElements. Allvalues above this are reserved for custom use. Therefore,custom values must be greater than this value.</ul><p> <p>See also <a href="#SubControl-enum">SubControl</a> and <a href="#drawComplexControl">drawComplexControl</a>().<h3 class=fn><a name="ContentsType-enum"></a>QStyle::ContentsType</h3><p> This enum represents a ContentsType. It is used to calculate sizesfor the contents of various widgets.<ul><li><tt>QStyle::CT_PushButton</tt><li><tt>QStyle::CT_CheckBox</tt><li><tt>QStyle::CT_RadioButton</tt><li><tt>QStyle::CT_ToolButton</tt><li><tt>QStyle::CT_ComboBox</tt><li><tt>QStyle::CT_Splitter</tt><li><tt>QStyle::CT_DockWindow</tt><li><tt>QStyle::CT_ProgressBar</tt><li><tt>QStyle::CT_PopupMenuItem</tt></ul><p> <ul><li><tt>QStyle::CT_CustomBase</tt> - base value for custom ControlElements. Allvalues above this are reserved for custom use. Therefore,custom values must be greater than this value.</ul><p> <p>See also <a href="#sizeFromContents">sizeFromContents</a>().<h3 class=fn><a name="ControlElement-enum"></a>QStyle::ControlElement</h3><p> This enum represents a ControlElement. A ControlElement is part ofa widget that performs some action or displays information to the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -