Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 4048

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qstyleoption.cpp -->
  <title>QStyleOption Class | Qt Widgets 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QStyleOption</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtwidgets-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-variables">Public Variables</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QStyleOption Class</h1>
<!-- $$$QStyleOption-brief -->
<p>The <a href="qstyleoption.html">QStyleOption</a> class stores the parameters used by <a href="qstyle.html">QStyle</a> functions. <a href="#details">More...</a></p>
<!-- @@@QStyleOption -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QStyleOption&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><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="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>
</td></tr></table></div><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>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#OptionType-enum">OptionType</a></b> { SO_Button, SO_ComboBox, SO_Complex, SO_Default, ..., SO_ComplexCustomBase }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#StyleOptionType-enum">StyleOptionType</a></b> { Type }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#StyleOptionVersion-enum">StyleOptionVersion</a></b> { Version }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><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 rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#QStyleOption-1">QStyleOption</a></b>(const QStyleOption &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#dtor.QStyleOption">~QStyleOption</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#initFrom">initFrom</a></b>(const QWidget *<i>widget</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStyleOption &amp;</td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#operator-eq">operator=</a></b>(const QStyleOption &amp;<i>other</i>)</td></tr>
</table></div>
<a name="public-variables"></a>
<h2 id="public-variables">Public Variables</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Qt::LayoutDirection </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#direction-var">direction</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFontMetrics </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#fontMetrics-var">fontMetrics</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPalette </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#palette-var">palette</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#rect-var">rect</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStyle::State </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#state-var">state</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#styleObject-var">styleObject</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#type-var">type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#version-var">version</a></b></td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a></b>(const QStyleOption *<i>option</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qstyleoption.html#qstyleoption_cast-1">qstyleoption_cast</a></b>(QStyleOption *<i>option</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QStyleOption-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qstyleoption.html">QStyleOption</a> class stores the parameters used by <a href="qstyle.html">QStyle</a> functions.</p>
<p><a href="qstyleoption.html">QStyleOption</a> 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 <code>.</code> or <code>-&gt;</code> 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 <a href="qstyleoption.html">QStyleOption</a> objects on the stack. This combined with Qt's extensive use of <a href="../qtcore/implicit-sharing.html">implicit sharing</a> for types such as <a href="../qtcore/qstring.html">QString</a>, <a href="../qtgui/qpalette.html">QPalette</a>, and <a href="../qtgui/qcolor.html">QColor</a> ensures that no memory allocation needlessly takes place.</p>
<p>The following code snippet shows how to use a specific <a href="qstyleoption.html">QStyleOption</a> subclass to paint a push button:</p>
<pre class="cpp">

  <span class="type">void</span> MyPushButton<span class="operator">::</span>paintEvent(<span class="type"><a href="../qtgui/qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>)
  {
      <span class="type"><a href="qstyleoptionbutton.html">QStyleOptionButton</a></span> option;
      option<span class="operator">.</span>initFrom(<span class="keyword">this</span>);
      option<span class="operator">.</span>state <span class="operator">=</span> isDown() <span class="operator">?</span> <span class="type"><a href="qstyle.html">QStyle</a></span><span class="operator">::</span>State_Sunken : <span class="type"><a href="qstyle.html">QStyle</a></span><span class="operator">::</span>State_Raised;
      <span class="keyword">if</span> (isDefault())
          option<span class="operator">.</span>features <span class="operator">|</span><span class="operator">=</span> <span class="type"><a href="qstyleoptionbutton.html">QStyleOptionButton</a></span><span class="operator">::</span>DefaultButton;
      option<span class="operator">.</span>text <span class="operator">=</span> text();
      option<span class="operator">.</span>icon <span class="operator">=</span> icon();

      <span class="type"><a href="../qtgui/qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
      style()<span class="operator">-</span><span class="operator">&gt;</span>drawControl(<span class="type"><a href="qstyle.html">QStyle</a></span><span class="operator">::</span>CE_PushButton<span class="operator">,</span> <span class="operator">&amp;</span>option<span class="operator">,</span> <span class="operator">&amp;</span>painter<span class="operator">,</span> <span class="keyword">this</span>);
  }

</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 <a href="qstyleoption.html">QStyleOption</a> parameter, you often need to cast the <a href="qstyleoption.html">QStyleOption</a> 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 class="cpp">

  <span class="type">void</span> MyStyle<span class="operator">::</span>drawPrimitive(PrimitiveElement element<span class="operator">,</span>
                              <span class="keyword">const</span> <span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> <span class="operator">*</span>option<span class="operator">,</span>
                              <span class="type"><a href="../qtgui/qpainter.html">QPainter</a></span> <span class="operator">*</span>painter<span class="operator">,</span>
                              <span class="keyword">const</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>widget)
  {
      <span class="keyword">if</span> (element <span class="operator">=</span><span class="operator">=</span> PE_FrameFocusRect) {
          <span class="keyword">const</span> <span class="type"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></span> <span class="operator">*</span>focusRectOption <span class="operator">=</span>
                  qstyleoption_cast<span class="operator">&lt;</span><span class="keyword">const</span> <span class="type"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(option);
          <span class="keyword">if</span> (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 <code>option</code> points is not of the correct type.</p>
<p>For an example demonstrating how style options can be used, see the <a href="qtwidgets-widgets-styles-example.html">Styles</a> example.</p>
</div>
<p><b>See also </b><a href="qstyle.html">QStyle</a> and <a href="qstylepainter.html">QStylePainter</a>.</p>
<!-- @@@QStyleOption -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$OptionType$$$SO_Default$$$SO_FocusRect$$$SO_Button$$$SO_Tab$$$SO_MenuItem$$$SO_Frame$$$SO_ProgressBar$$$SO_ToolBox$$$SO_Header$$$SO_DockWidget$$$SO_ViewItem$$$SO_TabWidgetFrame$$$SO_TabBarBase$$$SO_RubberBand$$$SO_ToolBar$$$SO_GraphicsItem$$$SO_Complex$$$SO_Slider$$$SO_SpinBox$$$SO_ToolButton$$$SO_ComboBox$$$SO_TitleBar$$$SO_GroupBox$$$SO_SizeGrip$$$SO_CustomBase$$$SO_ComplexCustomBase -->
<h3 class="fn" id="OptionType-enum"><a name="OptionType-enum"></a>enum QStyleOption::<span class="name">OptionType</span></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>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Button</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign"><a href="qstyleoptionbutton.html">QStyleOptionButton</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ComboBox</code></td><td class="topAlign tblval"><code>0xf0004</code></td><td class="topAlign"><a href="qstyleoptioncombobox.html">QStyleOptionComboBox</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Complex</code></td><td class="topAlign tblval"><code>0xf0000</code></td><td class="topAlign"><a href="qstyleoptioncomplex.html">QStyleOptionComplex</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Default</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign"><a href="qstyleoption.html">QStyleOption</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_DockWidget</code></td><td class="topAlign tblval"><code>9</code></td><td class="topAlign"><a href="qstyleoptiondockwidget.html">QStyleOptionDockWidget</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_FocusRect</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Frame</code></td><td class="topAlign tblval"><code>5</code></td><td class="topAlign"><a href="qstyleoptionframe.html">QStyleOptionFrame</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_GraphicsItem</code></td><td class="topAlign tblval"><code>15</code></td><td class="topAlign"><a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_GroupBox</code></td><td class="topAlign tblval"><code>0xf0006</code></td><td class="topAlign"><a href="qstyleoptiongroupbox.html">QStyleOptionGroupBox</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Header</code></td><td class="topAlign tblval"><code>8</code></td><td class="topAlign"><a href="qstyleoptionheader.html">QStyleOptionHeader</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_MenuItem</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign"><a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ProgressBar</code></td><td class="topAlign tblval"><code>6</code></td><td class="topAlign"><a href="qstyleoptionprogressbar.html">QStyleOptionProgressBar</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_RubberBand</code></td><td class="topAlign tblval"><code>13</code></td><td class="topAlign"><a href="qstyleoptionrubberband.html">QStyleOptionRubberBand</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_SizeGrip</code></td><td class="topAlign tblval"><code>0xf0007</code></td><td class="topAlign"><a href="qstyleoptionsizegrip.html">QStyleOptionSizeGrip</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Slider</code></td><td class="topAlign tblval"><code>0xf0001</code></td><td class="topAlign"><a href="qstyleoptionslider.html">QStyleOptionSlider</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_SpinBox</code></td><td class="topAlign tblval"><code>0xf0002</code></td><td class="topAlign"><a href="qstyleoptionspinbox.html">QStyleOptionSpinBox</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_Tab</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign"><a href="qstyleoptiontab.html">QStyleOptionTab</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_TabBarBase</code></td><td class="topAlign tblval"><code>12</code></td><td class="topAlign"><a href="qstyleoptiontabbarbase.html">QStyleOptionTabBarBase</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_TabWidgetFrame</code></td><td class="topAlign tblval"><code>11</code></td><td class="topAlign"><a href="qstyleoptiontabwidgetframe.html">QStyleOptionTabWidgetFrame</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_TitleBar</code></td><td class="topAlign tblval"><code>0xf0005</code></td><td class="topAlign"><a href="qstyleoptiontitlebar.html">QStyleOptionTitleBar</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ToolBar</code></td><td class="topAlign tblval"><code>14</code></td><td class="topAlign"><a href="qstyleoptiontoolbar.html">QStyleOptionToolBar</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ToolBox</code></td><td class="topAlign tblval"><code>7</code></td><td class="topAlign"><a href="qstyleoptiontoolbox.html">QStyleOptionToolBox</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ToolButton</code></td><td class="topAlign tblval"><code>0xf0003</code></td><td class="topAlign"><a href="qstyleoptiontoolbutton.html">QStyleOptionToolButton</a></td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ViewItem</code></td><td class="topAlign tblval"><code>10</code></td><td class="topAlign"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a> (used in Interviews)</td></tr>
</table></div>
<p>The following values are used for custom controls:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="even"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_CustomBase</code></td><td class="topAlign tblval"><code>0xf00</code></td><td class="topAlign">Reserved for custom QStyleOptions; all custom controls values must be above this value</td></tr>
<tr><td class="topAlign"><code>QStyleOption::SO_ComplexCustomBase</code></td><td class="topAlign tblval"><code>0xf000000</code></td><td class="topAlign">Reserved for custom QStyleOptions; all custom complex controls values must be above this value</td></tr>
</table></div>
<p><b>See also </b><a href="qstyleoption.html#type-var">type</a>.</p>
<!-- @@@OptionType -->
<!-- $$$StyleOptionType$$$Type -->
<h3 class="fn" id="StyleOptionType-enum"><a name="StyleOptionType-enum"></a>enum QStyleOption::<span class="name">StyleOptionType</span></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>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStyleOption::Type</code></td><td class="topAlign tblval"><code>SO_Default</code></td><td class="topAlign">The type of style option provided (<a href="qstyleoption.html#OptionType-enum">SO_Default</a> for this class).</td></tr>
</table></div>
<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><b>See also </b><a href="qstyleoption.html#StyleOptionVersion-enum">StyleOptionVersion</a>.</p>
<!-- @@@StyleOptionType -->
<!-- $$$StyleOptionVersion$$$Version -->
<h3 class="fn" id="StyleOptionVersion-enum"><a name="StyleOptionVersion-enum"></a>enum QStyleOption::<span class="name">StyleOptionVersion</span></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>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStyleOption::Version</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">1</td></tr>
</table></div>
<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><b>See also </b><a href="qstyleoption.html#StyleOptionType-enum">StyleOptionType</a>.</p>
<!-- @@@StyleOptionVersion -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QStyleOption[overload1]$$$QStyleOptionintint -->
<h3 class="fn" id="QStyleOption"><a name="QStyleOption"></a>QStyleOption::<span class="name">QStyleOption</span>(<span class="type">int</span> <i>version</i> = QStyleOption::Version, <span class="type">int</span> <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><b>See also </b><a href="qstyleoption.html#version-var">version</a> and <a href="qstyleoption.html#type-var">type</a>.</p>
<!-- @@@QStyleOption -->
<!-- $$$QStyleOption$$$QStyleOptionconstQStyleOption& -->
<h3 class="fn" id="QStyleOption-1"><a name="QStyleOption-1"></a>QStyleOption::<span class="name">QStyleOption</span>(const <span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> &amp;<i>other</i>)</h3>
<p>Constructs a copy of <i>other</i>.</p>
<!-- @@@QStyleOption -->
<!-- $$$~QStyleOption[overload1]$$$~QStyleOption -->
<h3 class="fn" id="dtor.QStyleOption"><a name="dtor.QStyleOption"></a>QStyleOption::<span class="name">~QStyleOption</span>()</h3>
<p>Destroys this style option object.</p>
<!-- @@@~QStyleOption -->
<!-- $$$initFrom[overload1]$$$initFromconstQWidget* -->
<h3 class="fn" id="initFrom"><a name="initFrom"></a><span class="type">void</span> QStyleOption::<span class="name">initFrom</span>(const <span class="type"><a href="qwidget.html">QWidget</a></span> *<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>, <a href="qstyleoption.html#fontMetrics-var">fontMetrics</a> and <a href="qstyleoption.html#styleObject-var">styleObject</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><b>See also </b><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>
<!-- @@@initFrom -->
<!-- $$$operator=[overload1]$$$operator=constQStyleOption& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> &amp;QStyleOption::<span class="name">operator=</span>(const <span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> &amp;<i>other</i>)</h3>
<p>Assign <i>other</i> to this <a href="qstyleoption.html">QStyleOption</a>.</p>
<!-- @@@operator= -->
</div>
<div class="vars">
<h2>Member Variable Documentation</h2>
<!-- $$$direction -->
<h3 class="fn" id="direction-var"><a name="direction-var"></a><span class="type"><a href="../qtcore/qt.html#LayoutDirection-enum">Qt::LayoutDirection</a></span> QStyleOption::<span class="name">direction</span></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="../qtcore/qt.html#LayoutDirection-enum">Qt::LeftToRight</a>.</p>
<p><b>See also </b><a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<!-- @@@direction -->
<!-- $$$fontMetrics -->
<h3 class="fn" id="fontMetrics-var"><a name="fontMetrics-var"></a><span class="type"><a href="../qtgui/qfontmetrics.html">QFontMetrics</a></span> QStyleOption::<span class="name">fontMetrics</span></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><b>See also </b><a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<!-- @@@fontMetrics -->
<!-- $$$palette -->
<h3 class="fn" id="palette-var"><a name="palette-var"></a><span class="type"><a href="../qtgui/qpalette.html">QPalette</a></span> QStyleOption::<span class="name">palette</span></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><b>See also </b><a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<!-- @@@palette -->
<!-- $$$rect -->
<h3 class="fn" id="rect-var"><a name="rect-var"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QStyleOption::<span class="name">rect</span></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><b>See also </b><a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<!-- @@@rect -->
<!-- $$$state -->
<h3 class="fn" id="state-var"><a name="state-var"></a><span class="type"><a href="qstyle.html#StateFlag-enum">QStyle::State</a></span> QStyleOption::<span class="name">state</span></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><b>See also </b><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>
<!-- @@@state -->
<!-- $$$styleObject -->
<h3 class="fn" id="styleObject-var"><a name="styleObject-var"></a><span class="type"><a href="../qtcore/qobject.html">QObject</a></span> *QStyleOption::<span class="name">styleObject</span></h3>
<p>This variable holds the object being styled</p>
<p>The built-in styles support the following types: <a href="qwidget.html">QWidget</a>, <a href="qgraphicsobject.html">QGraphicsObject</a> and QQuickItem.</p>
<p><b>See also </b><a href="qstyleoption.html#initFrom">initFrom</a>().</p>
<!-- @@@styleObject -->
<!-- $$$type -->
<h3 class="fn" id="type-var"><a name="type-var"></a><span class="type">int</span> QStyleOption::<span class="name">type</span></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><b>See also </b><a href="qstyleoption.html#OptionType-enum">OptionType</a>.</p>
<!-- @@@type -->
<!-- $$$version -->
<h3 class="fn" id="version-var"><a name="version-var"></a><span class="type">int</span> QStyleOption::<span class="name">version</span></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>
<!-- @@@version -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qstyleoption_cast[overload1]$$$qstyleoption_castconstQStyleOption* -->
<h3 class="fn" id="qstyleoption_cast"><a name="qstyleoption_cast"></a><span class="type">T</span> <span class="name">qstyleoption_cast</span>(const <span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> *<i>option</i>)</h3>
<p>Returns a T or 0 depending on the <a href="qstyleoption.html#type-var">type</a> and <a href="qstyleoption.html#version-var">version</a> of the given <i>option</i>.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type">void</span> MyStyle<span class="operator">::</span>drawPrimitive(PrimitiveElement element<span class="operator">,</span>
                              <span class="keyword">const</span> <span class="type"><a href="qstyleoption.html">QStyleOption</a></span> <span class="operator">*</span>option<span class="operator">,</span>
                              <span class="type"><a href="../qtgui/qpainter.html">QPainter</a></span> <span class="operator">*</span>painter<span class="operator">,</span>
                              <span class="keyword">const</span> <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>widget)
  {
      <span class="keyword">if</span> (element <span class="operator">=</span><span class="operator">=</span> PE_FrameFocusRect) {
          <span class="keyword">const</span> <span class="type"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></span> <span class="operator">*</span>focusRectOption <span class="operator">=</span>
                  qstyleoption_cast<span class="operator">&lt;</span><span class="keyword">const</span> <span class="type"><a href="qstyleoptionfocusrect.html">QStyleOptionFocusRect</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(option);
          <span class="keyword">if</span> (focusRectOption) {
              <span class="comment">// ...</span>
          }
      }
      <span class="comment">// ...</span>
  }

</pre>
<p><b>See also </b><a href="qstyleoption.html#type-var">QStyleOption::type</a> and <a href="qstyleoption.html#version-var">QStyleOption::version</a>.</p>
<!-- @@@qstyleoption_cast -->
<!-- $$$qstyleoption_cast$$$qstyleoption_castQStyleOption* -->
<h3 class="fn" id="qstyleoption_cast-1"><a name="qstyleoption_cast-1"></a><span class="type">T</span> <span class="name">qstyleoption_cast</span>(<span class="type"><a href="qstyleoption.html#QStyleOption">QStyleOption</a></span> *<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>
<!-- @@@qstyleoption_cast -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>