<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.16.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Grantlee: Grantlee for application developers</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Grantlee<span id="projectnumber">&#160;5.3.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.16.1 -->
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search',false);
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="doc-content">
<div><div class="header">
  <div class="headertitle"><div class="title">Grantlee for application developers </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Integrating Grantlee into applications is very simple. This page describes</p>
<ul>
<li>How to render a <a class="el" href="classGrantlee_1_1Template.html" title="The Template class is a tree of nodes which may be rendered.">Template</a> with a <a class="el" href="classGrantlee_1_1Context.html" title="The Context class holds the context to render a Template with.">Context</a> </li>
<li>How to load Templates </li>
<li>How to extend the syntax of Grantlee </li>
<li>Patterns of use of Grantlee</li>
</ul>
<p>If you are not already familiar with Django template syntax and structure, start with <a class="el" href="for_themers.html" title="Grantlee for theme artists">Grantlee for theme artists</a>. If you are already familiar with Django, you might find <a class="el" href="differences_django.html" title="Differences between Django and Grantlee">Differences between Django and Grantlee</a> informative.</p>
<h1 class="doxsection"><a class="anchor" id="rendering_templates"></a>
Rendering Templates</h1>
<h2 class="doxsection"><a class="anchor" id="creating_templates"></a>
Creating Templates</h2>
<p>Rendering templates is very easy in application code. A single <a class="el" href="classGrantlee_1_1Template.html" title="The Template class is a tree of nodes which may be rendered.">Template</a> may be rendered multiple times with different <a class="el" href="classGrantlee_1_1Context.html" title="The Context class holds the context to render a Template with.">Context</a> objects.</p>
<div class="fragment"><div class="line"><span class="keyword">auto</span> engine = <span class="keyword">new</span> <a class="code hl_class" href="classGrantlee_1_1Engine.html">Grantlee::Engine</a>( <span class="keyword">this</span> );</div>
<div class="line"><span class="keyword">auto</span> t = engine-&gt;newTemplate(<span class="stringliteral">&quot;My name is {{ name }}.&quot;</span>, <span class="stringliteral">&quot;my_template_name&quot;</span>);</div>
<div class="line">QVariantHash mapping;</div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;name&quot;</span>, <span class="stringliteral">&quot;Grainne&quot;</span>);</div>
<div class="line"><a class="code hl_class" href="classGrantlee_1_1Context.html">Grantlee::Context</a> c(mapping);</div>
<div class="line"> </div>
<div class="line">t-&gt;render(&amp;c); <span class="comment">// Returns &quot;My name is Grainne.&quot;</span></div>
<div class="line"> </div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;name&quot;</span>, <span class="stringliteral">&quot;Henry&quot;</span>);</div>
<div class="line">c = <a class="code hl_class" href="classGrantlee_1_1Context.html">Grantlee::Context</a>(mapping);</div>
<div class="line"> </div>
<div class="line">t-&gt;render(&amp;c); <span class="comment">// Returns &quot;My name is Henry.&quot;</span></div>
<div class="ttc" id="aclassGrantlee_1_1Context_html"><div class="ttname"><a href="classGrantlee_1_1Context.html">Grantlee::Context</a></div><div class="ttdoc">The Context class holds the context to render a Template with.</div><div class="ttdef"><b>Definition</b> <a href="context_8h_source.html#l00117">context.h:118</a></div></div>
<div class="ttc" id="aclassGrantlee_1_1Engine_html"><div class="ttname"><a href="classGrantlee_1_1Engine.html">Grantlee::Engine</a></div><div class="ttdoc">Grantlee::Engine is the main entry point for creating Grantlee Templates.</div><div class="ttdef"><b>Definition</b> <a href="engine_8h_source.html#l00120">engine.h:121</a></div></div>
</div><!-- fragment --><p>Usually, applications do not create a <a class="el" href="classGrantlee_1_1Template.html" title="The Template class is a tree of nodes which may be rendered.">Template</a> directly, but instead use a <a class="el" href="classGrantlee_1_1Engine.html" title="Grantlee::Engine is the main entry point for creating Grantlee Templates.">Grantlee::Engine</a> to load external files. This allows artists to define the template without needing to recompile.</p>
<div class="fragment"><div class="line"><span class="keyword">auto</span> t = engine-&gt;loadByName(<span class="stringliteral">&quot;template.html&quot;</span>);</div>
<div class="line"> </div>
<div class="line">t-&gt;render(&amp;c)</div>
</div><!-- fragment --><h2 class="doxsection"><a class="anchor" id="variables"></a>
Variables</h2>
<p>A <a class="el" href="classGrantlee_1_1Context.html" title="The Context class holds the context to render a Template with.">Context</a> object maps a string to another object for reference in the template. String keys in the <a class="el" href="classGrantlee_1_1Context.html" title="The Context class holds the context to render a Template with.">Context</a> object are available as variables in the <a class="el" href="classGrantlee_1_1Template.html" title="The Template class is a tree of nodes which may be rendered.">Template</a>, and can be used with the <span class="tt">{{&#160;variable&#160;}}</span> syntax or inside <span class="tt">{%&#160;control&#160;tags&#160;%}</span>. In the above example, we mapped the string <span class="tt">"name"</span> to the string <span class="tt">"Grainne"</span> and then to the string <span class="tt">"Henry"</span>. We can create more than just string mappings though.</p>
<div class="fragment"><div class="line">mapping.insert(<span class="stringliteral">&quot;myint&quot;</span>, 6); <span class="comment">// Can insert ints</span></div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;mydouble&quot;</span>, 6.5); <span class="comment">// Can insert doubles</span></div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;mybool&quot;</span>, <span class="keyword">false</span>); <span class="comment">// Can insert bools</span></div>
<div class="line"> </div>
<div class="line">QVariantList mylist{<span class="stringliteral">&quot;Ingrid&quot;</span>, 3};</div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;mylist&quot;</span>, mylist); <span class="comment">// Can insert QVariantList</span></div>
<div class="line"> </div>
<div class="line">QVariantHash myhash;</div>
<div class="line">myhash.insert(<span class="stringliteral">&quot;James&quot;</span>, <span class="stringliteral">&quot;Artist&quot;</span>);</div>
<div class="line">myhash.insert(<span class="stringliteral">&quot;Kiera&quot;</span>, <span class="stringliteral">&quot;Dreamer&quot;</span>);</div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;myhash&quot;</span>, myhash); <span class="comment">// Can insert QVariantHash</span></div>
<div class="line"> </div>
<div class="line">QObject *obj = getObj();</div>
<div class="line"><span class="keyword">auto</span> objVar = QVariant::fromValue(obj);</div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;myobject&quot;</span>, objVar); <span class="comment">// Can insert QObject*</span></div>
</div><!-- fragment --><p>It is additionally possible to insert any type of object or any container (not just QVariantHash and QVariantList) into the <a class="el" href="classGrantlee_1_1Context.html" title="The Context class holds the context to render a Template with.">Context</a>. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="generic_types_and_templates.html" title="Generic type and template support">Generic type and template support</a>.</dd></dl>
<h1 class="doxsection"><a class="anchor" id="extending_grantlee"></a>
Extending Grantlee</h1>
<p>Grantlee has 5 extension points.</p>
<ul>
<li>Custom object variables</li>
<li>Generic types and containers</li>
<li>Filters</li>
<li>Tags</li>
<li>Loaders</li>
</ul>
<h2 class="doxsection"><a class="anchor" id="custom_objects"></a>
Custom objects</h2>
<p>Instances of <span class="tt">QObject*</span> can be inserted into templates. The recommended way to insert custom objects into templates is to create QObject wrappers for your objects. As QObject is introspectable, this will allow lookups to work in a way you define.</p>
<dl class="section note"><dt>Note</dt><dd>If you are already familiar with Django you will know that creating wrappers is not necessary in Django. That is because python objects are already fully introspectable.</dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;myperson.h&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">class </span>PersonWrapper : <span class="keyword">public</span> QObject</div>
<div class="line">{</div>
<div class="line">  Q_OBJECT</div>
<div class="line">  Q_PROPERTY(QString name READ name)</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  PersonWrapper(<span class="keyword">const</span> QString &amp;name, <span class="keywordtype">int</span> age);</div>
<div class="line"> </div>
<div class="line">  QString name() <span class="keyword">const</span>;</div>
<div class="line"> </div>
<div class="line">  <span class="keywordtype">int</span> age() <span class="keyword">const</span>;</div>
<div class="line"> </div>
<div class="line">  QString clear();</div>
<div class="line"> </div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">auto linda = <span class="keyword">new</span> PersonWrapper(<span class="stringliteral">&quot;Linda&quot;</span>, 21);</div>
<div class="line"> </div>
<div class="line">mapping.insert(<span class="stringliteral">&quot;person&quot;</span>, linda);</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The name is {{ person.name }} and age is {{ person.age }}.</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Will be rendered as</span></div>
<div class="line"><span class="comment">// The name is Linda and age is .</span></div>
</div><!-- fragment --><p>Note that the <span class="tt">'name'</span> of <span class="tt">PersonWrapper</span> is accessible in the template, but the <span class="tt">'age'</span> is not. Note also that rendering fails silently if the method can not be found. Only methods which have a corresponding <span class="tt">Q_PROPERTY</span> declaration are accessible from templates. To make <span class="tt">age</span> accessible in the template, we would need to add</p>
<pre class="fragment">  Q_PROPERTY(int age READ age)
</pre><p>to the class. Note also that those methods are <span class="tt">const</span>. Rendering a template should never change an object it is rendering. Always make sure the READ properties of your wrapper objects are <span class="tt">const</span>. It is also possible to lookup dynamic properties of <span class="tt">QObject</span>s. In the case of dynamic properties, the property name must be UTF-8 encoded.</p>
<p>If you already have <span class="tt">QObject</span>s in your application which would be suitable for use in templates, you only need to add some <span class="tt">Q_PROPERTY</span> entries to the classes to make them accessible to Grantlee.</p>
<dl class="section note"><dt>Note</dt><dd>If you are familiar with Django you may be aware of the <span class="tt">alters_data</span> attribute for methods. This method of using wrappers and <span class="tt">const</span> is the equivalent to the <span class="tt">alters_data</span> attribute. You the wrapper writer choose the properties which will be accessible from the templates and makes them <span class="tt">const</span>, so there's no need to mark other methods as <span class="tt">alters_data</span>.</dd></dl>
<p>For most uses of Grantlee, this is enough to get make an application themable easily and quickly. For more advanced usage, see <a class="el" href="extension.html" title="Extending the template system">Extending the template system</a>. For some example uses of Grantlee, see <a class="el" href="examples.html" title="Examples of Grantlee use">Examples of Grantlee use</a>.</p>
<h2 class="doxsection"><a class="anchor" id="custom_object_properties"></a>
Custom Object Properties</h2>
<p>The broad introspection features of Qt5 are relied upon by Grantlee via the <span class="tt">Q_PROPERTY</span> macro. Most types used with that macro may be accessed in Grantlee templates without further code.</p>
<p>We can define a <span class="tt">Home</span> type like this:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>Home : <span class="keyword">public</span> QObject</div>
<div class="line">{</div>
<div class="line">    Q_OBJECT</div>
<div class="line">    Q_PROPERTY(<span class="keywordtype">int</span> houseNumber READ houseNumber)</div>
<div class="line">    Q_PROPERTY(QString streetName READ streetName)</div>
<div class="line">    Q_PROPERTY(QString city READ city)</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">    <span class="comment">// ...</span></div>
<div class="line">};</div>
</div><!-- fragment --><p>And we can use it in a <span class="tt">Q_PROPERTY</span> macro in our <span class="tt">PersonWrapper</span> type:</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>PersonWrapper : <span class="keyword">public</span> QObject</div>
<div class="line">{</div>
<div class="line">  Q_OBJECT</div>
<div class="line">  Q_PROPERTY(QString name READ name)</div>
<div class="line">  Q_PROPERTY(Home* home READ home)</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  PersonWrapper(<span class="keyword">const</span> QString &amp;name, <span class="keywordtype">int</span> age, Home *home);</div>
<div class="line"> </div>
<div class="line">  Home* home() <span class="keyword">const</span>;</div>
<div class="line"> </div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line">}</div>
</div><!-- fragment --><p>And then use it in a template:</p>
<div class="fragment"><div class="line">&lt;h1&gt;{{ person.name }}&lt;/h1&gt;</div>
<div class="line">House number: {{ person.home.houseNumber }}</div>
<div class="line">Street: {{ person.home.streetName }}</div>
</div><!-- fragment --><p>Using containers such as QList and QSharedPointer with the <span class="tt">Q_PROPERTY</span> macro is also possible.</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>PersonWrapper : <span class="keyword">public</span> QObject</div>
<div class="line">{</div>
<div class="line">  Q_OBJECT</div>
<div class="line">  Q_PROPERTY(QString name READ name)</div>
<div class="line">  Q_PROPERTY(QList&lt;PersonWrapper*&gt; friends READ friends)</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  PersonWrapper(<span class="keyword">const</span> QString &amp;name, <span class="keywordtype">int</span> age, Home *home);</div>
<div class="line"> </div>
<div class="line">  QList&lt;PersonWrapper&gt; friends()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_friends; }</div>
<div class="line">  <span class="keywordtype">void</span> setFriends(<span class="keyword">const</span> QList&lt;PersonWrapper*&gt; friends) { m_friends = friends; }</div>
<div class="line"> </div>
<div class="line">  <span class="comment">// ...</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">private</span>:</div>
<div class="line">  QList&lt;PersonWrapper*&gt; m_friends;</div>
<div class="line">};</div>
</div><!-- fragment --><p>Classes which do not derive from QObject, but which are decorated with the <span class="tt">Q_GADGET</span> and <span class="tt">&lt;Q_PROPERTY/tt&gt; macros may also be used as expected.</span></p>
<p><span class="tt"></span></p>
<h2 class="doxsection"><a class="anchor" id="generic_variables"></a>
<span class="tt">generic_variables</span></h2>
<p><span class="tt"></span></p>
<p><span class="tt">An alternative to writing wrapper QObject classes with <span class="tt">Q_PROPERTY</span> macros is to use the Grantlee::MetaType system to provide introspection for any type or any container. This subject is treated in detail in <a class="el" href="generic_types_and_templates.html" title="Generic type and template support">Generic type and template support</a></span></p>
<p><span class="tt"></span></p>
<h2 class="doxsection"><a class="anchor" id="enumerator_variables"></a>
<span class="tt">Enumerators</span></h2>
<p><span class="tt"></span></p>
<p><span class="tt">Grantlee has built-in support for enumerators which use the <span class="tt">Q_ENUMS</span> macro.</span></p>
<p><span class="tt"></p><div class="fragment"><div class="line"><span class="keyword">class </span>MyClass : <span class="keyword">public</span> QObject</div>
<div class="line">{</div>
<div class="line">  Q_OBJECT</div>
<div class="line">  Q_ENUMS(PersonName)</div>
<div class="line">  Q_PROPERTY(PersonName personName READ personName)</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"> </div>
<div class="line">  <span class="keyword">enum</span> PersonName</div>
<div class="line">  {</div>
<div class="line">    Mike,</div>
<div class="line">    Natalie,</div>
<div class="line">    Oliver,</div>
<div class="line">    Patrica = 9</div>
<div class="line">    Quentin</div>
<div class="line">  };</div>
<div class="line"> </div>
<div class="line">  MyClass(QObject *parent = 0 );</div>
<div class="line"> </div>
<div class="line">  PersonName personName()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> Quentin; }</div>
<div class="line"> </div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">{</div>
<div class="line">  QObject *<span class="keywordtype">object</span> = <span class="keyword">new</span> MyClass(<span class="keyword">this</span>);</div>
<div class="line">  context.insert(<span class="stringliteral">&quot;myObj&quot;</span>, <span class="keywordtype">object</span>);</div>
<div class="line">  t-&gt;render(context);</div>
<div class="line">}</div>
</div><!-- fragment --><p></span></p>
<p><span class="tt">The enums can be used and accessed in various ways. See QMetaEnum for details.</span></p>
<p><span class="tt"></p><div class="fragment"><div class="line">Oliver is value {{ myObj.Oliver }}.</div>
<div class="line"><span class="comment">// Output: &quot;Oliver is value 2&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Oliver key is {{ myObj.Oliver.key }}.</div>
<div class="line"><span class="comment">// Output: &quot;Oliver key is Oliver&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Oliver value is {{ myObj.Oliver.value }}.</div>
<div class="line"><span class="comment">// Output: &quot;Oliver value is 2&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Oliver scope is {{ myObj.Oliver.scope }}.</div>
<div class="line"><span class="comment">// Output: &quot;Oliver scope is MyClass&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Oliver scope is {{ myObj.Oliver.name }}.</div>
<div class="line"><span class="comment">// Output: &quot;Oliver scope is PersonName&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Patrica is value {{ myObj.Patrica }}.</div>
<div class="line"><span class="comment">// Output: &quot;Patrica is value 9&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">PersonName has {{ myObj.PersonName.keyCount }} items.</div>
<div class="line"><span class="comment">// Output: &quot;PersonName has 5 items&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Second item is {{ myObj.PersonName.1 }}.</div>
<div class="line"><span class="comment">// Output: &quot;Second item is 1&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Second item is {{ myObj.PersonName.1.key }}.</div>
<div class="line"><span class="comment">// Output: &quot;Second item is Natalie&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Fourth item is {{ myObj.PersonName.3 }}.</div>
<div class="line"><span class="comment">// Output: &quot;Fourth item is 9&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">Fourth item is {{ myObj.PersonName.3.key }}.</div>
<div class="line"><span class="comment">// Output: &quot;Fourth item is Patrica&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The personName <span class="keyword">property</span> is {{ myObj.personName }}.</div>
<div class="line"><span class="comment">// Output: &quot;The personName property is 10&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The personName <span class="keyword">property</span> is {{ myObj.personName.key }}.</div>
<div class="line"><span class="comment">// Output: &quot;The personName property is Quentin&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The personName type is {{ myObj.personName.scope }}.</div>
<div class="line"><span class="comment">// Output: &quot;The personName type is PersonName&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The personName is {% with myObj.personName as var %}{{ var }}, {{ var.key }}{% endwith %}.</div>
<div class="line"><span class="comment">// Output: &quot;The personName is 10, Quentin&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The <span class="keyword">enum</span> is {% with myObj.PersonName as <span class="keyword">enum</span> %}{{ <span class="keyword">enum</span>.3 }}, {{ <span class="keyword">enum</span>.4 }}, {{ <span class="keyword">enum</span>.4.key }}{% endwith %}.</div>
<div class="line"><span class="comment">// Output: &quot;The enum is 9, 10, Quentin&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The <span class="keyword">enum</span> is {% <span class="keywordflow">for</span> <span class="keyword">enum</span> in myObj.PersonName %}{{ <span class="keyword">enum</span> }} : {{ <span class="keyword">enum</span>.key }}, {% endfor %}.</div>
<div class="line"><span class="comment">// Output: &quot;The enum 0 : Mike, 1 : Natalie, 2 : Oliver, 9 : Patrica, 10 : Quentin, &quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The <span class="keyword">enum</span> is {% <span class="keywordflow">for</span> <span class="keyword">enum</span> in myObj.PersonName %}</div>
<div class="line">                {% ifequal <span class="keyword">enum</span> Oliver %}**{{ <span class="keyword">enum</span> }} : {{ <span class="keyword">enum</span>.key }}**</div>
<div class="line">                {% <span class="keywordflow">else</span> %}{{ <span class="keyword">enum</span> }} : {{ <span class="keyword">enum</span>.key }},</div>
<div class="line">                {% endifequal %}</div>
<div class="line">            {% endfor %}.</div>
<div class="line"><span class="comment">// Output: &quot;The enum 0 : Mike, 1 : Natalie, **2 : Oliver**, 9 : Patrica, 10 : Quentin, &quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">The <span class="keyword">enum</span> is {% <span class="keywordflow">for</span> <span class="keyword">enum</span> in myObj.PersonName %}</div>
<div class="line">                {% ifequal <span class="keyword">enum</span> myObj.personName %}**{{ <span class="keyword">enum</span> }} : {{ <span class="keyword">enum</span>.key }}**</div>
<div class="line">                {% <span class="keywordflow">else</span> %}{{ <span class="keyword">enum</span> }} : {{ <span class="keyword">enum</span>.key }},</div>
<div class="line">                {% endifequal %}</div>
<div class="line">            {% endfor %}.</div>
<div class="line"><span class="comment">// Output: &quot;The enum 0 : Mike, 1 : Natalie, 2 : Oliver, 9 : Patrica, **10 : Quentin**, &quot;.</span></div>
</div><!-- fragment --><p></span></p>
<p><span class="tt">Enumerators in the Qt namespaces are also supported.</span></p>
<p><span class="tt"></p><div class="fragment"><div class="line">AlignRight value is {{ Qt.AlignRight }}.</div>
<div class="line"><span class="comment">// Output: &quot;AlignRight value is 2&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">AlignRight key is {{ Qt.AlignRight.key }}.</div>
<div class="line"><span class="comment">// Output: &quot;AlignRight value is AlignRight&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">AlignRight scope is {{ Qt.AlignRight.scope }}.</div>
<div class="line"><span class="comment">// Output: &quot;AlignRight scope is Qt&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">AlignRight name is {{ Qt.AlignRight.name }}.</div>
<div class="line"><span class="comment">// Output: &quot;AlignRight scope is Alignment&quot;.</span></div>
<div class="line"> </div>
<div class="line">...</div>
<div class="line"> </div>
<div class="line">{% ifequal myObj.alignment Qt.AlignRight %}RightAligned{% <span class="keywordflow">else</span> %}Not RightAligned{% endifequal %}.</div>
<div class="line"><span class="comment">// Output: &quot;RightAligned&quot;. or &quot;Not RightAligned&quot;, depending on the value of myObj.alignment.</span></div>
<div class="line"> </div>
<div class="line">...</div>
</div><!-- fragment --><p>
</span></p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1
</small></address>
</div><!-- doc-content -->
</body>
</html>
