Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ac91357d6caede925de099a02fced14e > files > 4068

qt4-doc-4.2.1-1.el5_7.1.x86_64.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">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/corelib/global/qglobal.cpp -->
<head>
  <title>Qt 4.2: QFlags Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" 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="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QFlags Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1>
<p>The QFlags class provides a type-safe way of storing OR-combinations of enum values. <a href="#details">More...</a></p>
<pre> #include &lt;QFlags&gt;</pre><ul>
<li><a href="qflags-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>typedef <b><a href="qflags.html#enum_type-typedef">enum_type</a></b></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qflags.html#QFlags">QFlags</a></b> ( const QFlags &amp; <i>other</i> )</li>
<li><div class="fn"/><b><a href="qflags.html#QFlags-2">QFlags</a></b> ( Enum <i>flag</i> )</li>
<li><div class="fn"/><b><a href="qflags.html#QFlags-3">QFlags</a></b> ( Zero <i>zero</i> = 0 )</li>
<li><div class="fn"/><b><a href="qflags.html#QFlags-4">QFlags</a></b> ( QFlag <i>value</i> )</li>
<li><div class="fn"/>bool <b><a href="qflags.html#testFlag">testFlag</a></b> ( Enum <i>flag</i> ) const</li>
<li><div class="fn"/><b><a href="qflags.html#operator-int">operator int</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qflags.html#operator-not">operator!</a></b> () const</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-and">operator&amp;</a></b> ( int <i>mask</i> ) const</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-and-2">operator&amp;</a></b> ( uint <i>mask</i> ) const</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-and-3">operator&amp;</a></b> ( Enum <i>mask</i> ) const</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-and-eq">operator&amp;=</a></b> ( int <i>mask</i> )</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-and-eq-2">operator&amp;=</a></b> ( uint <i>mask</i> )</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-eq">operator=</a></b> ( const QFlags &amp; <i>other</i> )</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-5e">operator^</a></b> ( QFlags <i>other</i> ) const</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-5e-2">operator^</a></b> ( Enum <i>other</i> ) const</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-5e-eq">operator^=</a></b> ( QFlags <i>other</i> )</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-5e-eq-2">operator^=</a></b> ( Enum <i>other</i> )</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-7c">operator|</a></b> ( QFlags <i>other</i> ) const</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-7c-2">operator|</a></b> ( Enum <i>other</i> ) const</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-7c-eq">operator|=</a></b> ( QFlags <i>other</i> )</li>
<li><div class="fn"/>QFlags &amp; <b><a href="qflags.html#operator-7c-eq-2">operator|=</a></b> ( Enum <i>other</i> )</li>
<li><div class="fn"/>QFlags <b><a href="qflags.html#operator-7e">operator~</a></b> () const</li>
</ul>
<a name="macros"></a>
<h3>Macros</h3>
<ul>
<li><div class="fn"/><b><a href="qflags.html#Q_DECLARE_FLAGS">Q_DECLARE_FLAGS</a></b> (  <i>Flags</i>,  <i>Enum</i> )</li>
<li><div class="fn"/><b><a href="qflags.html#Q_DECLARE_OPERATORS_FOR_FLAGS">Q_DECLARE_OPERATORS_FOR_FLAGS</a></b> (  <i>Flags</i> )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QFlags class provides a type-safe way of storing OR-combinations of enum values.</p>
<p>The QFlags&lt;Enum&gt; class is a template class, where Enum is an enum type. QFlags is used throughout Qt for storing combinations of enum values.</p>
<p>The traditional C++ approach for storing OR-combinations of enum values is to use an <tt>int</tt> or <tt>uint</tt> variable. The inconvenience with this approach is that there's no type checking at all; any enum value can be OR'd with any other enum value and passed on to a function that takes an <tt>int</tt> or <tt>uint</tt>.</p>
<p>Qt uses QFlags to provide type safety. For example, the <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a> type is simply a typedef for QFlags&lt;<a href="qt.html#AlignmentFlag-enum">Qt::AlignmentFlag</a>&gt;. <a href="qlabel.html#alignment-prop">QLabel::setAlignment</a>() takes a <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a> parameter, which means that any combination of <a href="qt.html#AlignmentFlag-enum">Qt::AlignmentFlag</a> values is legal:</p>
<pre> label-&gt;setAlignment(Qt::AlignLeft | Qt::AlignTop);</pre>
<p>If you try to pass a value from another enum, the compiler will report an error.</p>
<p>If you want to use QFlags for your own enum types, use the <a href="qflags.html#Q_DECLARE_FLAGS">Q_DECLARE_FLAGS</a>() and <a href="qflags.html#Q_DECLARE_OPERATORS_FOR_FLAGS">Q_DECLARE_OPERATORS_FOR_FLAGS</a>(). For example:</p>
<pre> class MyClass
 {
 public:
     enum Option {
         NoOptions = 0x0,
         ShowTabs = 0x1,
         ShowAll = 0x2,
         SqueezeBlank = 0x4
     };
     Q_DECLARE_FLAGS(Options, Option)
     ...
 };

 Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)</pre>
<p>You can then use the <tt>MyClass::Options</tt> type to store combinations of <tt>MyClass::Option</tt> values.</p>
<p>A sensible naming convension for enum types and associated QFlags types is to give a singular name to the enum type (e.g., <tt>Option</tt>) and a plural name to the QFlags type (e.g., <tt>Options</tt>). When a singular name is desired for the QFlags type (e.g., <tt>Alignment</tt>), you can use <tt>Flag</tt> as the suffix for the enum type (e.g., <tt>AlignmentFlag</tt>).</p>
<p>See also <a href="qflag.html">QFlag</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="enum_type-typedef"></a>typedef QFlags::enum_type</h3>
<p>Typedef for the Enum template type.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QFlags"></a>QFlags::QFlags ( const QFlags &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<h3 class="fn"><a name="QFlags-2"></a>QFlags::QFlags ( Enum <i>flag</i> )</h3>
<p>Constructs a <a href="qflags.html">QFlags</a> object storing the given <i>flag</i>.</p>
<h3 class="fn"><a name="QFlags-3"></a>QFlags::QFlags ( Zero <i>zero</i> = 0 )</h3>
<p>Constructs a <a href="qflags.html">QFlags</a> object with no flags set. <i>zero</i> must be a literal 0 value.</p>
<h3 class="fn"><a name="QFlags-4"></a>QFlags::QFlags ( <a href="qflag.html">QFlag</a> <i>value</i> )</h3>
<p>Constructs a <a href="qflags.html">QFlags</a> object initialized with the given integer <i>value</i>.</p>
<p>The <a href="qflag.html">QFlag</a> type is a helper type. By using it here instead of <tt>int</tt>, we effectively ensure that arbitrary enum values cannot be cast to a <a href="qflags.html">QFlags</a>, whereas untyped enum values (i.e., <tt>int</tt> values) can.</p>
<h3 class="fn"><a name="testFlag"></a>bool QFlags::testFlag ( Enum <i>flag</i> ) const</h3>
<p>Returns true if the <i>flag</i> is set, otherwise false.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="operator-int"></a>QFlags::operator int () const</h3>
<p>Returns the value stored in the <a href="qflags.html">QFlags</a> object as an integer.</p>
<h3 class="fn"><a name="operator-not"></a>bool QFlags::operator! () const</h3>
<p>Returns true if no flag is set (i.e., if the value stored by the <a href="qflags.html">QFlags</a> object is 0); otherwise returns false.</p>
<h3 class="fn"><a name="operator-and"></a>QFlags QFlags::operator&amp; ( int <i>mask</i> ) const</h3>
<p>Returns a <a href="qflags.html">QFlags</a> object containing the result of the bitwise AND operation on this object and <i>mask</i>.</p>
<p>See also <a href="qflags.html#operator-and-eq">operator&amp;=</a>(), <a href="qflags.html#operator-7c">operator|</a>(), <a href="qflags.html#operator-5e">operator^</a>(), and <a href="qflags.html#operator-7e">operator~</a>().</p>
<h3 class="fn"><a name="operator-and-2"></a>QFlags QFlags::operator&amp; ( <a href="qtglobal.html#uint-typedef">uint</a> <i>mask</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-and-3"></a>QFlags QFlags::operator&amp; ( Enum <i>mask</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-and-eq"></a>QFlags &amp; QFlags::operator&amp;= ( int <i>mask</i> )</h3>
<p>Performs a bitwise AND operation with <i>mask</i> and stores the result in this <a href="qflags.html">QFlags</a> object. Returns a reference to this object.</p>
<p>See also <a href="qflags.html#operator-and">operator&amp;</a>(), <a href="qflags.html#operator-7c-eq">operator|=</a>(), and <a href="qflags.html#operator-5e-eq">operator^=</a>().</p>
<h3 class="fn"><a name="operator-and-eq-2"></a>QFlags &amp; QFlags::operator&amp;= ( <a href="qtglobal.html#uint-typedef">uint</a> <i>mask</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-eq"></a>QFlags &amp; QFlags::operator= ( const QFlags &amp; <i>other</i> )</h3>
<p>Assigns <i>other</i> to this object and returns a reference to this object.</p>
<h3 class="fn"><a name="operator-5e"></a>QFlags QFlags::operator^ ( QFlags <i>other</i> ) const</h3>
<p>Returns a <a href="qflags.html">QFlags</a> object containing the result of the bitwise XOR operation on this object and <i>other</i>.</p>
<p>See also <a href="qflags.html#operator-5e-eq">operator^=</a>(), <a href="qflags.html#operator-and">operator&amp;</a>(), <a href="qflags.html#operator-7c">operator|</a>(), and <a href="qflags.html#operator-7e">operator~</a>().</p>
<h3 class="fn"><a name="operator-5e-2"></a>QFlags QFlags::operator^ ( Enum <i>other</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-5e-eq"></a>QFlags &amp; QFlags::operator^= ( QFlags <i>other</i> )</h3>
<p>Performs a bitwise XOR operation with <i>other</i> and stores the result in this <a href="qflags.html">QFlags</a> object. Returns a reference to this object.</p>
<p>See also <a href="qflags.html#operator-5e">operator^</a>(), <a href="qflags.html#operator-and-eq">operator&amp;=</a>(), and <a href="qflags.html#operator-7c-eq">operator|=</a>().</p>
<h3 class="fn"><a name="operator-5e-eq-2"></a>QFlags &amp; QFlags::operator^= ( Enum <i>other</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-7c"></a>QFlags QFlags::operator| ( QFlags <i>other</i> ) const</h3>
<p>Returns a <a href="qflags.html">QFlags</a> object containing the result of the bitwise OR operation on this object and <i>other</i>.</p>
<p>See also <a href="qflags.html#operator-7c-eq">operator|=</a>(), <a href="qflags.html#operator-5e">operator^</a>(), <a href="qflags.html#operator-and">operator&amp;</a>(), and <a href="qflags.html#operator-7e">operator~</a>().</p>
<h3 class="fn"><a name="operator-7c-2"></a>QFlags QFlags::operator| ( Enum <i>other</i> ) const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-7c-eq"></a>QFlags &amp; QFlags::operator|= ( QFlags <i>other</i> )</h3>
<p>Performs a bitwise OR operation with <i>other</i> and stores the result in this <a href="qflags.html">QFlags</a> object. Returns a reference to this object.</p>
<p>See also <a href="qflags.html#operator-7c">operator|</a>(), <a href="qflags.html#operator-and-eq">operator&amp;=</a>(), and <a href="qflags.html#operator-5e-eq">operator^=</a>().</p>
<h3 class="fn"><a name="operator-7c-eq-2"></a>QFlags &amp; QFlags::operator|= ( Enum <i>other</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="operator-7e"></a>QFlags QFlags::operator~ () const</h3>
<p>Returns a <a href="qflags.html">QFlags</a> object that contains the bitwise negation of this object.</p>
<p>See also <a href="qflags.html#operator-and">operator&amp;</a>(), <a href="qflags.html#operator-7c">operator|</a>(), and <a href="qflags.html#operator-5e">operator^</a>().</p>
<hr />
<h2>Macro Documentation</h2>
<h3 class="fn"><a name="Q_DECLARE_FLAGS"></a>Q_DECLARE_FLAGS (  <i>Flags</i>,  <i>Enum</i> )</h3>
<p>The Q_DECLARE_FLAGS() macro expands to</p>
<pre> typedef QFlags&lt;Enum&gt; Flags;</pre>
<p><i>Enum</i> is the name of an existing enum type, whereas <i>Flags</i> is the name of the <a href="qflags.html">QFlags</a>&lt;<i>Enum</i>&gt; typedef.</p>
<p>See the <a href="qflags.html">QFlags</a> documentation for details.</p>
<p>See also <a href="qflags.html#Q_DECLARE_OPERATORS_FOR_FLAGS">Q_DECLARE_OPERATORS_FOR_FLAGS</a>().</p>
<h3 class="fn"><a name="Q_DECLARE_OPERATORS_FOR_FLAGS"></a>Q_DECLARE_OPERATORS_FOR_FLAGS (  <i>Flags</i> )</h3>
<p>The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global <tt>operator|()</tt> functions for <i>Flags</i>, which is of type <a href="qflags.html">QFlags</a>&lt;T&gt;.</p>
<p>See the <a href="qflags.html">QFlags</a> documentation for details.</p>
<p>See also <a href="qflags.html#Q_DECLARE_FLAGS">Q_DECLARE_FLAGS</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>