Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4986

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qstyleoption.cpp -->
<head>
  <title>Qt 4.6: QStyleOption Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QStyleOption"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QStyleOption Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span>
</h1>
<p>The QStyleOption class stores the parameters used by <a href="qstyle.html">QStyle</a> functions. <a href="#details">More...</a></p>
<pre> #include &lt;QStyleOption&gt;</pre><p>Inherited by <a href="qstyleoptionbutton.html">QStyleOptionButton</a>, <a href="qstyleoptioncomplex.html">QStyleOptionComplex</a>, <a href="qstyleoptiondockwidget.html">QStyleOptionDockWidget</a>, <a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a>, <a href="qstyleoptionframe.html">QStyleOptionFrame</a>, <a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a>, <a href="qstyleoptionheader.html">QStyleOptionHeader</a>, <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a>, <a href="qstyleoptionprogressbar.html">QStyleOptionProgressBar</a>, <a href="qstyleoptionq3dockwindow.html">QStyleOptionQ3DockWindow</a>, <a href="qstyleoptionq3listviewitem.html">QStyleOptionQ3ListViewItem</a>, <a href="qstyleoptionrubberband.html">QStyleOptionRubberBand</a>, <a href="qstyleoptiontab.html">QStyleOptionTab</a>, <a href="qstyleoptiontabbarbase.html">QStyleOptionTabBarBase</a>, <a href="qstyleoptiontabwidgetframe.html">QStyleOptionTabWidgetFrame</a>, <a href="qstyleoptiontoolbar.html">QStyleOptionToolBar</a>, <a href="qstyleoptiontoolbox.html">QStyleOptionToolBox</a>, and <a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a>.</p>
<ul>
<li><a href="qstyleoption-members.html">List of all members, including inherited members</a></li>
<li><a href="qstyleoption-obsolete.html">Obsolete members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#OptionType-enum">OptionType</a></b> { SO_Button, SO_ComboBox, SO_Complex, SO_Default, ..., SO_Q3ListViewItem }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#StyleOptionType-enum">StyleOptionType</a></b> { Type }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#StyleOptionVersion-enum">StyleOptionVersion</a></b> { Version }</td></tr>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#QStyleOption">QStyleOption</a></b> ( int <i>version</i> = QStyleOption::Version, int <i>type</i> = SO_Default )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#QStyleOption-2">QStyleOption</a></b> ( const QStyleOption &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#dtor.QStyleOption">~QStyleOption</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#initFrom">initFrom</a></b> ( const QWidget * <i>widget</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QStyleOption &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#operator-eq">operator=</a></b> ( const QStyleOption &amp; <i>other</i> )</td></tr>
</table>
<hr />
<a name="public-variables"></a>
<h2>Public Variables</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">Qt::LayoutDirection </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#direction-var">direction</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QFontMetrics </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#fontMetrics-var">fontMetrics</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QPalette </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#palette-var">palette</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QRect </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#rect-var">rect</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QStyle::State </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#state-var">state</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#type-varx">type</a></b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#version-var">version</a></b></td></tr>
</table>
<hr />
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a></b> ( const QStyleOption * <i>option</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qstyleoption.html#qstyleoption_cast-3">qstyleoption_cast</a></b> ( QStyleOption * <i>option</i> )</td></tr>
</table>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QStyleOption class stores the parameters used by <a href="qstyle.html">QStyle</a> functions.</p>
<p>QStyleOption and its subclasses contain all the information that <a href="qstyle.html">QStyle</a> functions need to draw a graphical element.</p>
<p>For performance reasons, there are few member functions and the access to the member variables is direct (i.e&#x2e;, using the <tt>.</tt> or <tt>-&gt;</tt> operator). This low-level feel makes the structures straightforward to use and emphasizes that these are simply parameters used by the style functions.</p>
<p>The caller of a <a href="qstyle.html">QStyle</a> function usually creates QStyleOption objects on the stack. This combined with Qt's extensive use of <a href="implicit-sharing.html">implicit sharing</a> for types such as <a href="qstring.html">QString</a>, <a href="qpalette.html">QPalette</a>, and <a href="qcolor.html">QColor</a> ensures that no memory allocation needlessly takes place.</p>
<p>The following code snippet shows how to use a specific QStyleOption subclass to paint a push button:</p>
<pre> void MyPushButton::paintEvent(QPaintEvent *)
 {
     QStyleOptionButton option;
     option.initFrom(this);
     option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
     if (isDefault())
         option.features |= QStyleOptionButton::DefaultButton;
     option.text = text();
     option.icon = icon();

     QPainter painter(this);
     style()-&gt;drawControl(QStyle::CE_PushButton, &amp;option, &amp;painter, this);
 }</pre>
<p>In our example, the control is a <a href="qstyle.html#ControlElement-enum">QStyle::CE_PushButton</a>, and according to the <a href="qstyle.html#drawControl">QStyle::drawControl</a>() documentation the corresponding class is <a href="qstyleoptionbutton.html">QStyleOptionButton</a>.</p>
<p>When reimplementing <a href="qstyle.html">QStyle</a> functions that take a QStyleOption parameter, you often need to cast the QStyleOption to a subclass. For safety, you can use <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() to ensure that the pointer type is correct. For example:</p>
<pre> void MyStyle::drawPrimitive(PrimitiveElement element,
                             const QStyleOption *option,
                             QPainter *painter,
                             const QWidget *widget)
 {
     if (element == PE_FrameFocusRect) {
         const QStyleOptionFocusRect *focusRectOption =
                 qstyleoption_cast&lt;const QStyleOptionFocusRect *&gt;(option);
         if (focusRectOption) {
             <span class="comment">// ...</span>
         }
     }
     <span class="comment">// ...</span>
 }</pre>
<p>The <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() function will return 0 if the object to which <tt>option</tt> points is not of the correct type.</p>
<p>For an example demonstrating how style options can be used, see the <a href="widgets-styles.html">Styles</a> example.</p>
<p>See also <a href="qstyle.html">QStyle</a> and <a href="qstylepainter.html">QStylePainter</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tag/QStyleOption/OptionType"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Button"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ComboBox"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Complex"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Default"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_DockWidget"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_FocusRect"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Frame"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_GraphicsItem"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_GroupBox"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Header"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_MenuItem"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ProgressBar"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_RubberBand"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_SizeGrip"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Slider"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_SpinBox"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Tab"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_TabBarBase"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_TabWidgetFrame"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_TitleBar"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ToolBar"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ToolBox"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ToolButton"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ViewItem"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_CustomBase"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_ComplexCustomBase"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Q3DockWindow"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Q3ListView"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/SO_Q3ListViewItem"></a>
<h3 class="fn"><a name="OptionType-enum"></a>enum QStyleOption::OptionType</h3>
<p>This enum is used internally by <a href="qstyleoption.html">QStyleOption</a>, its subclasses, and <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() to determine the type of style option. In general you do not need to worry about this unless you want to create your own <a href="qstyleoption.html">QStyleOption</a> subclass and your own styles.</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Button</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top"><a href="qstyleoptionbutton.html">QStyleOptionButton</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ComboBox</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptioncombobox.html">QStyleOptionComboBox</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Complex</tt></td><td align="center" valign="top"><tt>0xf0000</tt></td><td valign="top"><a href="qstyleoptioncomplex.html">QStyleOptionComplex</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Default</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top"><a href="qstyleoption.html">QStyleOption</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_DockWidget</tt></td><td align="center" valign="top"><tt>10</tt></td><td valign="top"><a href="qstyleoptiondockwidget.html">QStyleOptionDockWidget</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_FocusRect</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Frame</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top"><a href="qstyleoptionframe.html">QStyleOptionFrame</a> <a href="qstyleoptionframev2.html">QStyleOptionFrameV2</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_GraphicsItem</tt></td><td align="center" valign="top"><tt>17</tt></td><td valign="top"><a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_GroupBox</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptiongroupbox.html">QStyleOptionGroupBox</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Header</tt></td><td align="center" valign="top"><tt>8</tt></td><td valign="top"><a href="qstyleoptionheader.html">QStyleOptionHeader</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_MenuItem</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top"><a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ProgressBar</tt></td><td align="center" valign="top"><tt>6</tt></td><td valign="top"><a href="qstyleoptionprogressbar.html">QStyleOptionProgressBar</a> <a href="qstyleoptionprogressbarv2.html">QStyleOptionProgressBarV2</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_RubberBand</tt></td><td align="center" valign="top"><tt>15</tt></td><td valign="top"><a href="qstyleoptionrubberband.html">QStyleOptionRubberBand</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_SizeGrip</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptionsizegrip.html">QStyleOptionSizeGrip</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Slider</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptionslider.html">QStyleOptionSlider</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_SpinBox</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptionspinbox.html">QStyleOptionSpinBox</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Tab</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top"><a href="qstyleoptiontab.html">QStyleOptionTab</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_TabBarBase</tt></td><td align="center" valign="top"><tt>14</tt></td><td valign="top"><a href="qstyleoptiontabbarbase.html">QStyleOptionTabBarBase</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_TabWidgetFrame</tt></td><td align="center" valign="top"><tt>13</tt></td><td valign="top"><a href="qstyleoptiontabwidgetframe.html">QStyleOptionTabWidgetFrame</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_TitleBar</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptiontitlebar.html">QStyleOptionTitleBar</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ToolBar</tt></td><td align="center" valign="top"><tt>16</tt></td><td valign="top"><a href="qstyleoptiontoolbar.html">QStyleOptionToolBar</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ToolBox</tt></td><td align="center" valign="top"><tt>7</tt></td><td valign="top"><a href="qstyleoptiontoolbox.html">QStyleOptionToolBox</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ToolButton</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptiontoolbutton.html">QStyleOptionToolButton</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ViewItem</tt></td><td align="center" valign="top"><tt>12</tt></td><td valign="top"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a> (used in Interviews)</td></tr>
</table></p>
<p>The following values are used for custom controls:</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QStyleOption::SO_CustomBase</tt></td><td align="center" valign="top"><tt>0xf00</tt></td><td valign="top">Reserved for custom QStyleOptions; all custom controls values must be above this value</td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_ComplexCustomBase</tt></td><td align="center" valign="top"><tt>0xf000000</tt></td><td valign="top">Reserved for custom QStyleOptions; all custom complex controls values must be above this value</td></tr>
</table></p>
<p>Some style options are defined for various <a href="qt3support.html">Qt3Support</a> controls:</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Q3DockWindow</tt></td><td align="center" valign="top"><tt>9</tt></td><td valign="top"><a href="qstyleoptionq3dockwindow.html">QStyleOptionQ3DockWindow</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Q3ListView</tt></td><td align="center" valign="top">?</td><td valign="top"><a href="qstyleoptionq3listview.html">QStyleOptionQ3ListView</a></td></tr>
<tr><td valign="top"><tt>QStyleOption::SO_Q3ListViewItem</tt></td><td align="center" valign="top"><tt>11</tt></td><td valign="top"><a href="qstyleoptionq3listviewitem.html">QStyleOptionQ3ListViewItem</a></td></tr>
</table></p>
<p>See also <a href="qstyleoption.html#type-varx">type</a>.</p>
<a name="//apple_ref/cpp/tag/QStyleOption/StyleOptionType"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/Type"></a>
<h3 class="fn"><a name="StyleOptionType-enum"></a>enum QStyleOption::StyleOptionType</h3>
<p>This enum is used to hold information about the type of the style option, and is defined for each <a href="qstyleoption.html">QStyleOption</a> subclass.</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QStyleOption::Type</tt></td><td align="center" valign="top"><tt>SO_Default</tt></td><td valign="top">The type of style option provided (<a href="qstyleoption.html#OptionType-enum">SO_Default</a> for this class).</td></tr>
</table></p>
<p>The type is used internally by <a href="qstyleoption.html">QStyleOption</a>, its subclasses, and <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() to determine the type of style option. In general you do not need to worry about this unless you want to create your own <a href="qstyleoption.html">QStyleOption</a> subclass and your own styles.</p>
<p>See also <a href="qstyleoption.html#StyleOptionVersion-enum">StyleOptionVersion</a>.</p>
<a name="//apple_ref/cpp/tag/QStyleOption/StyleOptionVersion"></a>
<a name="//apple_ref/cpp/econst/QStyleOption/Version"></a>
<h3 class="fn"><a name="StyleOptionVersion-enum"></a>enum QStyleOption::StyleOptionVersion</h3>
<p>This enum is used to hold information about the version of the style option, and is defined for each <a href="qstyleoption.html">QStyleOption</a> subclass.</p>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QStyleOption::Version</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">1</td></tr>
</table></p>
<p>The version is used by <a href="qstyleoption.html">QStyleOption</a> subclasses to implement extensions without breaking compatibility. If you use <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>(), you normally do not need to check it.</p>
<p>See also <a href="qstyleoption.html#StyleOptionType-enum">StyleOptionType</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QStyleOption/QStyleOption"></a>
<h3 class="fn"><a name="QStyleOption"></a>QStyleOption::QStyleOption ( int <i>version</i> = QStyleOption::Version, int <i>type</i> = SO_Default )</h3>
<p>Constructs a <a href="qstyleoption.html">QStyleOption</a> with the specified <i>version</i> and <i>type</i>.</p>
<p>The version has no special meaning for <a href="qstyleoption.html">QStyleOption</a>; it can be used by subclasses to distinguish between different version of the same option type.</p>
<p>The <a href="qstyleoption.html#state-var">state</a> member variable is initialized to <a href="qstyle.html#StateFlag-enum">QStyle::State_None</a>.</p>
<p>See also <a href="qstyleoption.html#version-var">version</a> and <a href="qstyleoption.html#type-varx">type</a>.</p>
<h3 class="fn"><a name="QStyleOption-2"></a>QStyleOption::QStyleOption ( const QStyleOption &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<a name="//apple_ref/cpp/instm/QStyleOption/~QStyleOption"></a>
<h3 class="fn"><a name="dtor.QStyleOption"></a>QStyleOption::~QStyleOption ()</h3>
<p>Destroys this style option object.</p>
<a name="//apple_ref/cpp/instm/QStyleOption/initFrom"></a>
<h3 class="fn"><a name="initFrom"></a>void QStyleOption::initFrom ( const <a href="qwidget.html">QWidget</a> * <i>widget</i> )</h3>
<p>Initializes the <a href="qstyleoption.html#state-var">state</a>, <a href="qstyleoption.html#direction-var">direction</a>, <a href="qstyleoption.html#rect-var">rect</a>, <a href="qstyleoption.html#palette-var">palette</a>, and <a href="qstyleoption.html#fontMetrics-var">fontMetrics</a> member variables based on the specified <i>widget</i>.</p>
<p>This is a convenience function; the member variables can also be initialized manually.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qwidget.html#layoutDirection-prop">QWidget::layoutDirection</a>(), <a href="qwidget.html#rect-prop">QWidget::rect</a>(), <a href="qwidget.html#palette-prop">QWidget::palette</a>(), and <a href="qwidget.html#fontMetrics">QWidget::fontMetrics</a>().</p>
<a name="//apple_ref/cpp/instm/QStyleOption/operator="></a>
<h3 class="fn"><a name="operator-eq"></a>QStyleOption &amp; QStyleOption::operator= ( const QStyleOption &amp; <i>other</i> )</h3>
<p>Assign <i>other</i> to this <a href="qstyleoption.html">QStyleOption</a>.</p>
<hr />
<h2>Member Variable Documentation</h2>
<a name="//apple_ref/cpp/data/QStyleOption/direction"></a>
<h3 class="fn"><a name="direction-var"></a><a href="qt.html#LayoutDirection-enum">Qt::LayoutDirection</a> QStyleOption::direction</h3>
<p>This variable holds the text layout direction that should be used when drawing text in the control.</p>
<p>By default, the layout direction is <a href="qt.html#LayoutDirection-enum">Qt::LeftToRight</a>.</p>
<p>See also <a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<a name="//apple_ref/cpp/data/QStyleOption/fontMetrics"></a>
<h3 class="fn"><a name="fontMetrics-var"></a><a href="qfontmetrics.html">QFontMetrics</a> QStyleOption::fontMetrics</h3>
<p>This variable holds the font metrics that should be used when drawing text in the control.</p>
<p>By default, the application's default font is used.</p>
<p>See also <a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<a name="//apple_ref/cpp/data/QStyleOption/palette"></a>
<h3 class="fn"><a name="palette-var"></a><a href="qpalette.html">QPalette</a> QStyleOption::palette</h3>
<p>This variable holds the palette that should be used when painting the control.</p>
<p>By default, the application's default palette is used.</p>
<p>See also <a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<a name="//apple_ref/cpp/data/QStyleOption/rect"></a>
<h3 class="fn"><a name="rect-var"></a><a href="qrect.html">QRect</a> QStyleOption::rect</h3>
<p>This variable holds the area that should be used for various calculations and painting.</p>
<p>This can have different meanings for different types of elements. For example, for a <a href="qstyle.html#ControlElement-enum">QStyle::CE_PushButton</a> element it would be the rectangle for the entire button, while for a <a href="qstyle.html#ControlElement-enum">QStyle::CE_PushButtonLabel</a> element it would be just the area for the push button label.</p>
<p>The default value is a null rectangle, i.e&#x2e; a rectangle with both the width and the height set to 0.</p>
<p>See also <a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<a name="//apple_ref/cpp/data/QStyleOption/state"></a>
<h3 class="fn"><a name="state-var"></a><a href="qstyle.html#StateFlag-enum">QStyle::State</a> QStyleOption::state</h3>
<p>This variable holds the style flags that are used when drawing the control.</p>
<p>The default value is <a href="qstyle.html#StateFlag-enum">QStyle::State_None</a>.</p>
<p>See also <a href="qstyleoption.html#initFrom">initFrom</a>(), <a href="qstyle.html#drawPrimitive">QStyle::drawPrimitive</a>(), <a href="qstyle.html#drawControl">QStyle::drawControl</a>(), <a href="qstyle.html#drawComplexControl">QStyle::drawComplexControl</a>(), and <a href="qstyle.html#StateFlag-enum">QStyle::State</a>.</p>
<a name="//apple_ref/cpp/data/QStyleOption/type"></a>
<h3 class="fn"><a name="type-varx"></a>int QStyleOption::type</h3>
<p>This variable holds the option type of the style option.</p>
<p>The default value is <a href="qstyleoption.html#OptionType-enum">SO_Default</a>.</p>
<p>See also <a href="qstyleoption.html#OptionType-enum">OptionType</a>.</p>
<a name="//apple_ref/cpp/data/QStyleOption/version"></a>
<h3 class="fn"><a name="version-var"></a>int QStyleOption::version</h3>
<p>This variable holds the version of the style option.</p>
<p>This value can be used by subclasses to implement extensions without breaking compatibility. If you use the <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() function, you normally do not need to check it.</p>
<p>The default value is 1.</p>
<hr />
<h2>Related Non-Members</h2>
<a name="//apple_ref/cpp/func//qstyleoption_cast"></a>
<h3 class="fn"><a name="qstyleoption_cast"></a>T qstyleoption_cast ( const QStyleOption * <i>option</i> )</h3>
<p>Returns a T or 0 depending on the <a href="qstyleoption.html#type-varx">type</a> and <a href="qstyleoption.html#version-var">version</a> of the given <i>option</i>.</p>
<p>Example:</p>
<pre> void MyStyle::drawPrimitive(PrimitiveElement element,
                             const QStyleOption *option,
                             QPainter *painter,
                             const QWidget *widget)
 {
     if (element == PE_FrameFocusRect) {
         const QStyleOptionFocusRect *focusRectOption =
                 qstyleoption_cast&lt;const QStyleOptionFocusRect *&gt;(option);
         if (focusRectOption) {
             <span class="comment">// ...</span>
         }
     }
     <span class="comment">// ...</span>
 }</pre>
<p>See also <a href="qstyleoption.html#type-varx">QStyleOption::type</a> and <a href="qstyleoption.html#version-var">QStyleOption::version</a>.</p>
<h3 class="fn"><a name="qstyleoption_cast-3"></a>T qstyleoption_cast ( QStyleOption * <i>option</i> )</h3>
<p>This is an overloaded function.</p>
<p>Returns a T or 0 depending on the type of the given <i>option</i>.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>