<?xml version="1.0" encoding="utf-8"?>	
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>Qt Wiki</title>
    <link>http://developer.qt.nokia.com/wiki</link>
    <description>Qt Wiki</description>
    <dc:language>en</dc:language>
    <dc:creator>qt-devnet@nokia.com</dc:creator>
    <dc:rights>Copyright 2012 Qt Developer Network</dc:rights>
    <dc:date>2012-02-23T04:04:06+00:00</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />
    

    <item>
      <title>Qt_5.0</title>
      <link>http://developer.qt.nokia.com/wiki/Qt_5.0</link>
      <guid>http://developer.qt.nokia.com/wiki/Qt_5.0</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#a85a62a1b5264a92dd306d252cde953e">Qt 5.0 Roadmap </a><ul>
<li><a href="#6bdb6ada1918803eccdaeec8266683d3">Mission of release</a></li>
<li><a href="#ed49a36c4fd547e5e2ace11bef4f21cf">Platforms</a></li>
<li><a href="#66036ddf6d03c9ce1fc742741417f128">Modules </a><ul>
<li><a href="#c95933f534ffae9a505878758e63faca">Qt Essentials</a></li>
<li><a href="#91291c28bfd413309e6e0944bc4bf941">Qt Add-Ons</a></li></ul>
</li>
<li><a href="#5a22bc49e87612584eed75bba239c837">Timelines</a></li></ul>
</li></ul>
</div>

	<a name="a85a62a1b5264a92dd306d252cde953e"></a>	<h1>Qt 5.0 Roadmap </h1>

	<p><span class="caps">NOTE</span>: this page is work in progress, needs review.</p>

	<a name="6bdb6ada1918803eccdaeec8266683d3"></a>	<h2>Mission of release</h2>

	<p>Qt 5.0 will be the foundation for a new way of developing applications, where Qt Quick is in the center of Qt. Qt 5 continues to offer all of the power of native Qt C++, and we don&#8217;t want Qt 5 to be disruptive for existing code developed for Qt 4.  </p>

	<p>Qt 5 enables highly sophisticated user experiences, offering applications the full capabilities of OpenGL/OpenGL ES graphics acceleration. In this respect, Qt 5.0 is a feature-driven release with time-to-market requirements especially for embedded environments. This implies that we should keep the scope of Qt 5.0 limited to the essential, and add more features and add-on modules in the upcoming minor releases.</p>

	<ul>
		<li><a href="http://developer.qt.nokia.com/groups/qt_contributors_summit/wiki/Qt5ProductDefinition">Product Definition from QtCS/11</a> <em>[developer.qt.nokia.com]</em></li>
	</ul>

	<a name="ed49a36c4fd547e5e2ace11bef4f21cf"></a>	<h2>Platforms</h2>

	<p>We are targeting to have the following platform configurations as reference platforms for Qt 5.0, targeting to run them on the Continuous Integration system. On all platforms, Open GL (ES) 2.0 is required.</p>

<table class="infotable line"><tr style="background:#009900;"><th>Platform </th><th> Configuration in the CI system </th><th>Compilers </th><th>Notes </th></tr><tr><td> linux-x86-32-gcc-x11 </td><td> Ubuntu Linux 11.04 &#215;86 32 bit, X11                      </td><td> as provided </td><td> Ubuntu 10.04 may be too old </td></tr><tr style="background:#ddd;"><td> linux-x86-64-gcc-x11 </td><td> Ubuntu Linux 11.04 &#215;86 64 bit, X11                      </td><td> as provided </td><td> Ubuntu 10.04 may be too old </td></tr><tr><td> linux-x86-32-gcc-wayland </td><td> Linux, x86, 32-bit. To be specified in more detail      </td><td> gcc </td><td> </td></tr><tr style="background:#ddd;"><td> linux-arm7-gcc-wayland </td><td> Linux, ARM7, Wayland. To be specified in more detail     </td><td> gcc 4.5 ? </td><td>  CI will only cross-compile, no autotests? </td></tr><tr><td> windowsxp-32-gcc </td><td> Microsoft Windows XP SP3 32-bit                           </td><td> gcc 4.5 (MinGW) (32-bit) </td><td> gcc 4.4 is buggy and will not be fixed &#8211; will gcc 4.5 work?  </td></tr><tr style="background:#ddd;"><td> windows7-64-msvc2010</td><td> Microsoft Windows 7 64-bit                                   </td><td> <span class="caps">MSVC</span> 2010 SP1 64-bit </td><td> </td></tr><tr><td> windows7-32-msvc2010</td><td> Microsoft Windows 7 32-bit                                   </td><td> <span class="caps">MSVC</span> 2010 SP1 32-bit </td><td>  </td></tr><tr style="background:#ddd;"><td> osx-10.7-64 </td><td> Apple Mac OS X 10.7 &#8220;Lion&#8221; Cocoa 64 bit              </td><td> As provided by Apple </td><td> </td></tr></table>

	<p>In addition to the reference platform configurations, we would like to support the following configurations on Tier 1 level.</p>

<table class="infotable line"><tr style="background:#009900;"><th>Platform </th><th>Configuration in the CI    </th><th>Compilers</th><th>Notes </th></tr><tr><td> windowsxp-32-msvc2008</td><td> Microsoft Windows XP SP3 32-bit                           </td><td> <span class="caps">MSVC</span> 2008 32-bit </td><td> </td></tr><tr style="background:#ddd;"><td> windows7-32-msvc2008</td><td> Microsoft Windows 7 32-bit                                   </td><td> <span class="caps">MSVC</span> 2008 32-bit </td><td>  </td></tr><tr><td> windows8 </td><td> Windows 8 </td><td> <span class="caps">TBD</span> </td><td> Depends on Widows 8 schedule. We need to decide which combinations to include: 32/64, compilers  </td></tr><tr style="background:#ddd;"><td> linux-mips </td><td> Linux, <span class="caps">MIPS</span>           </td><td> ? </td><td> CI will only cross-compile, no autotests?  </td></tr><tr><td> windows7-32-icc </td><td> Microsoft Windows 7 32-bit                 </td><td> Intel Compiler  </td><td>  </td></tr><tr style="background:#ddd;"><td> linux-x86-32-icc-x11 </td><td> Linux Ubuntu 10.04 &#215;86 32-bit, X11   </td><td> Intel Compiler </td><td>  </td></tr><tr><td> linux-x86-32-icc-wayland</td><td> Linux Ubuntu 10.04 &#215;86 32-bit,  Wayland      </td><td> Intel Compiler </td><td> </td></tr><tr style="background:#ddd;"><td> osx-10.6-64 </td><td> Apple Mac OS X 10.6 &#8220;Snow Leopard&#8221; Cocoa 64 bit    </td><td> As provided by Apple </td><td>  </td></tr><tr><td> osx-10.6-32</td><td> Apple Mac OS X 10.6 &#8220;Snow Leopard&#8221; Cocoa 32 bit    </td><td> As provided by Apple </td><td>  </td></tr></table>

	<a name="66036ddf6d03c9ce1fc742741417f128"></a>	<h2>Modules </h2>

	<a name="c95933f534ffae9a505878758e63faca"></a>	<h3>Qt Essentials</h3>

	<p>The Qt Essentials for Qt 5.0 are listed here.</p>

<table class="infotable line"><tr style="background:#009900;"><th>Module </th><th>Notes. E.g. platform specific comments and additional dependencies </th></tr><tr><td> Qt Core </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Network </td><td> </td></tr><tr><td> Qt <span class="caps">GUI</span> </td><td> Includes OpenGL</td></tr><tr style="background:#ddd;"><td> Qt Quick 2 </td><td> </td></tr><tr><td> Qt Test </td><td> Needed for conformance testing but not required to be included in the release. No compatibility promise </td></tr><tr style="background:#ddd;"><td> Qt <span class="caps">SQL</span> </td><td> </td></tr><tr><td> V8 JavaScript engine </td><td>  </td></tr><tr style="background:#ddd;"><td> Qt D-Bus </td><td> Needed because of dependencies. not cross-platform </td></tr><tr><td> Qt WebKit </td><td> with a new low level C++ <span class="caps">API</span> and a <span class="caps">QML</span> <span class="caps">API</span> </td></tr><tr style="background:#ddd;"><td> Qt Multimedia </td><td> GStreamer on Linux. (Add Windows, Mac dependencies here, same as in Qt Mobility 1.2) </td></tr><tr><td> Qt Service Framework </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Publish and Subscribe </td><td> </td></tr><tr><td> Qt System Info </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Location </td><td> <span class="caps">NMEA</span> backend for positioning </td></tr><tr><td> Qt Sensors </td><td> </td></tr></table>

	<a name="91291c28bfd413309e6e0944bc4bf941"></a>	<h3>Qt Add-Ons</h3>

	<p>The following table documents the Qt Add-On modules and their platform support in Qt 5.0.</p>

<table class="infotable line"><tr style="background:#009900;"><th>Module </th><th>Platforms on which the module runs </th><th> Releases </th><th>Notes </th></tr><tr><td> Qt Widgets </td><td> All desktop platforms  </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Multimedia Widgets </td><td> All desktop platforms </td><td> </td><td> </td></tr><tr><td> Qt Quick 1 </td><td> All desktop platforms </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt WebKit (WebKit1 based <span class="caps">API</span>s) </td><td> All desktop platforms </td><td> </td><td> </td></tr><tr><td> Qt <span class="caps">SVG</span> </td><td> All platforms </td><td> </td><td>  </td></tr><tr style="background:#ddd;"><td> Qt <span class="caps">XML</span> </td><td> All platforms </td><td> </td><td> </td></tr><tr><td> Qt <span class="caps">XML</span> Patterns </td><td> All platforms. </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Script </td><td> All platforms. </td><td> </td><td> </td></tr><tr><td> Qt Script Tools </td><td> All platforms </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Concurrent </td><td> </td><td> </td><td> </td></tr><tr><td> Qt Organizer </td><td> All platforms (only &#8220;memory backend&#8221; which is useful for testing)  </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Contacts </td><td> All platforms (only &#8220;memory backend&#8221; which is useful for testing) </td><td> </td><td> </td></tr><tr><td> Qt Versit </td><td> All platforms </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Versit Organizer </td><td> All platforms </td><td> </td><td> </td></tr><tr><td> ActiveQt </td><td> All Windows configurations </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt 3D </td><td> All platforms </td><td> </td><td> an essential module Qt Location depends on Qt 3D (for maps support) </td></tr><tr><td> Qt Feedback </td><td> </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Graphical Effects </td><td> All platforms </td><td> </td><td> </td></tr><tr><td> Qt UI Tools </td><td> All desktop platforms </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Designer </td><td> All desktop platforms </td><td> </td><td> </td></tr><tr><td> Qt Help </td><td> All platforms  </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt CLucene </td><td> All platforms </td><td> </td><td> </td></tr><tr><td> Qt <span class="caps">MIME</span> Types </td><td> </td><td> </td><td> </td></tr><tr style="background:#ddd;"><td> Qt Print Support </td><td> </td><td> </td><td> </td></tr><tr><td> Qt Wayland </td><td> All Linux Wayland configurations </td><td> </td><td> includes Qt Compositor <span class="caps">API</span> (server), and Wayland platform plugin (clients) </td></tr><tr style="background:#ddd;"><td> Qt <span class="caps">JSON</span> DB </td><td> </td><td> </td><td> </td></tr></table>

	<p>Phonon will be maintained upstream by <span class="caps">KDE</span>.</p>

	<p>Open: Add Qt Quick components modules</p>

	<p>Open: whether Qt 5.0 will include the Qt Document Gallery add-on module.<br />
Open: whether Qt 5.0 will include the Qt Local connectivity add-on <br />
Open: whether Qt 5.0 will include the Qt Messaging add-on</p>

	<a name="5a22bc49e87612584eed75bba239c837"></a>	<h2>Timelines</h2>

	<p>Target schedule for Qt 5.0 release: 1st half of 2012</p>]]></description>
      <dc:subject>Qt_5.0</dc:subject>
      <dc:date>2012-02-23T04:04:06+00:00</dc:date>
    </item>

    <item>
      <title>Building_Qt_5_from_Git</title>
      <link>http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git</link>
      <guid>http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-5-from-Git-SimplifiedChinese">简体中文</a> <a href="http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git_Bulgarian">Български</a> <a href="http://developer.qt.nokia.com/wiki/Building_Qt_5_from_Git_French">Français</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#56bcccacb35592a3a8b372ac302b46c1">Building Qt 5 from Git</a><ul>
<li><a href="#0b79795d3efc95b9976c7c5b933afce2">Introduction</a></li>
<li><a href="#419cfc02b324dc7d8faefa90ed608fb0">System Requirements</a></li>
<li><a href="#b50aae10a392d80cb2253ce34e686ae3">Getting the source code</a></li>
<li><a href="#0cc5cbb2903cf6911ac1b6e3aa032572">Configuring and building</a></li>
<li><a href="#2763f33c904a183bd0ef06f9c4fb4403">Installing</a></li>
<li><a href="#0647f0776aed243f58bfec4dd81de863">Cleaning</a></li>
<li><a href="#1dbe9e8c128d0b3cafbeaef20b9082cf">Getting updates</a></li>
<li><a href="#181b27e32ae791e987cb19fced190543">Using master branches in the submodules</a></li>
<li><a href="#80b768b15c3693e345a436b9dc0ea36f">Issues</a></li>
<li><a href="#9832a8a505d2bd3352d26e84e88d0218">Questions & Comments</a></li></ul>
</li></ul>
</div>

	<a name="56bcccacb35592a3a8b372ac302b46c1"></a>	<h1>Building Qt 5 from Git</h1>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h2>Introduction</h2>

	<p>This article will try to give some hints for checking out the modularized Qt5 from git and getting it built. Please feel free to update this article as things change during development. Raise issues related to the article on <a href="http://developer.qt.nokia.com/forums/viewthread/7018">http://developer.qt.nokia.com/forums/viewthread/7018</a> .</p>

	<a name="419cfc02b324dc7d8faefa90ed608fb0"></a>	<h2>System Requirements</h2>

	<p>You need obviously git (&gt;= 1.6.x) to get the packages. To properly configure and build Qt 5 from source you also need Perl and Python, as well as a working compiler.</p>

	<a name="15e7b6ad3df43ff719f8388ab4afb1cc"></a>	<h3>Linux/X11</h3>

	<p>Libxcb is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro&#8217;s packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). </p>

	<p>For example: </p>

	<a name="33cf1c4fbb1a36146839478c3f142f40"></a>	<h4>on Ubuntu/Debian:</h4>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">sudo aptitude install ~nlibxcb.<span class="sy0">*</span></div></li>
</ol></div></p>

	<a name="e285695b96102d42e1af6be36a009a24"></a>	<h4>on Ubuntu/Oneiric:
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">sudo apt<span class="sy0">-</span>get install libxcb.<span class="sy0">*</span> libglu1<span class="sy0">-</span>mesa<span class="sy0">-</span>dev</div></li>
</ol></div></h4>

	<a name="2110b71f7fd182426738e1ceb11608d3"></a>	<h4>on Fedora:
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">su <span class="sy0">-</span> <span class="sy0">-</span>c <span class="st0">&quot;yum install libxcb libxcb-devel xcb-util xcb-util-devel gperf&quot;</span></div></li>
</ol></div></h4>

	<a name="cf8977e95459321cad5bdd3ebfd9844c"></a>	<h4>on ArchLinux:
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">sudo pacman <span class="sy0">-</span>S libxcb xcb<span class="sy0">-</span>proto xcb<span class="sy0">-</span>util xcb<span class="sy0">-</span>util<span class="sy0">-</span>image xcb<span class="sy0">-</span>util<span class="sy0">-</span>wm</div></li>
</ol></div></h4>

	<p>For QML2 a graphics driver with native OpenGL 2.0 support is highly recommended.</p>

	<a name="f895df5b37498f660cde1a2388d7af8b"></a>	<h3>Mac OS X</h3>

	<p>XCode and git should be enough.</p>

	<a name="aea23489ce3aa9b6406ebb28e0cda430"></a>	<h3>Windows</h3>

	<p>The commonly used compiler is Visual Studio (2008, 2010). MinGW (with gcc 4.6) might work too &#8230; </p>

	<p>For QML2 to work, you need an OpenGL driver (NVidia,etc) for your graphics card. The Windows default driver provides only OpenGL 1.1, which is not sufficient. </p>

	<p>You&#8217;ll also need both Python (e.g. Active Python 2.7 or higher) and Perl (e.g. Active State Perl 5.10 or higher) in the &#37;<span class="caps">PATH</span>&#37;. </p>

	<ul>
		<li>Hint: Check that Activate State Perl is found in the path before any outdated binaries, e.g. the ones that ship with msys-git.</li>
	</ul>

	<a name="b50aae10a392d80cb2253ce34e686ae3"></a>	<h2>Getting the source code</h2>

	<p>First clone the top-level qt5 git repository:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">git clone git<span class="sy0">:</span><span class="co1">//gitorious.org/qt/qt5.git qt5</span></div></li>
</ol></div></p>

	<p>or (if you&#8217;re behind a firewall and want to use the http protocol):</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">git clone http<span class="sy0">:</span><span class="co1">//gitorious.org/qt/qt5.git qt5</span></div></li>
</ol></div></p>

	<p>Following the <span class="caps">README</span> file we initialize the repository. This clones the various sub-modules of Qt5:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qt5</div></li>
<li class="li1"><div class="de1">perl init<span class="sy0">-</span>repository</div></li>
</ol></div></p>

	<p>If you plan to contribute to Qt, you should specify your <a href="http://developer.qt.nokia.com/wiki/Gerrit_Introduction">codereview username</a> so that the git remotes are properly set up:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">perl init<span class="sy0">-</span>repository <span class="sy0">--</span>codereview<span class="sy0">-</span>username <span class="sy0">&lt;</span>Jira<span class="sy0">/</span>Gerrit username<span class="sy0">&gt;</span> </div></li>
</ol></div></p>

	<ul>
		<li>Hint 1a: If you&#8217;re having problems downloading the webkit repository (which is quite big), you can pass &#8212;no-webkit. This module also takes a long time to compile and if often a source of compile errors, so it is recommend to only download it if you intend to use it.</li>
		<li>Hint 1b: You can run init-repository again with -f later to setup webkit if you need it, and have previously deselected it.</li>
		<li>Hint 2: If you&#8217;re behind a firewall, pass &#8212;http.</li>
		<li>Hint 3: You can sign up for a user name here: <a href="https://bugreports.qt.nokia.com/">https://bugreports.qt.nokia.com/</a></li>
	</ul>

	<a name="0cc5cbb2903cf6911ac1b6e3aa032572"></a>	<h2>Configuring and building</h2>

	<p>Setup your path so that we pick up the Qt5 tools rather than any old Qt4 ones that may be present on your system:</p>

	<p>For Linux:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">export QTDIR<span class="sy0">=</span>$PWD<span class="sy0">/</span>qtbase</div></li>
<li class="li1"><div class="de1">export PATH<span class="sy0">=</span>$PWD<span class="sy0">/</span>qtbase<span class="sy0">/</span>bin<span class="sy0">:</span>$PATH</div></li>
</ol></div></p>

	<p>For Windows:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">set QTDIR<span class="sy0">=%</span>CD<span class="sy0">%</span>\qtbase</div></li>
<li class="li1"><div class="de1">set PATH<span class="sy0">=%</span>CD<span class="sy0">%</span>\qtbase\bin<span class="sy0">;%</span>PATH<span class="sy0">%</span></div></li>
</ol></div></p>

	<p>Now configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">.<span class="sy0">/</span>configure <span class="sy0">-</span>developer<span class="sy0">-</span>build <span class="sy0">-</span>opensource <span class="sy0">-</span>nomake examples <span class="sy0">-</span>nomake tests</div></li>
</ol></div></p>

	<p>The <code>-developer-build</code> options export more symbols than in a traditional Qt build in order to allow more classes and functions to be unit tested. It also defaults to a &#8216;debug&#8217; build, and installs the binaries in the current directory, avoiding the need for &#8216;make install&#8217;. &#8216;-opensource&#8217; set&#8217;s the license to be <span class="caps">LGPL</span> 2.1. The <code>-nomake examples</code> and <code>-nomake tests</code> parameters make sure examples and tests aren&#8217;t compiled by default. You can always decide to compile them later by hand.</p>

	<ul>
		<li>Hint1: On Linux you should also pass -no-gtkstyle. This is because on a number of systems (at least <span class="caps">SUSE</span> and Gentoo) `pkg-config &#8212;cflags gtk+-2.0` actually returns paths that include the system Qt4.x include directories.</li>
	</ul>

	<ul>
		<li>Hint2: You can add -confirm-license to get rid of the question whether you agree to the license.</li>
	</ul>

	<p>Now make it as per usual (adjust -j option to suit number of cores + 1):</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">make <span class="sy0">-</span>j3</div></li>
</ol></div></p>

	<p>Or just make a specific module, e.g. declarative, and modules it depends on:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">make module<span class="sy0">-</span>qtdeclarative</div></li>
</ol></div></p>

	<a name="2763f33c904a183bd0ef06f9c4fb4403"></a>	<h2>Installing</h2>

	<ul>
		<li><strong>Note:</strong> Installation is only needed if you haven&#8217;t used the configure options <code>-developer-build</code> or <code>-prefix &#8220;.&#8221;</code>. Otherwise you can just use Qt from the build directory.</li>
	</ul>

	<p>To install, simply run</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">make install</div></li>
</ol></div></p>

	<p>But if you&#8217;re installing into a non-standard path for testing qt5, you&#8217;ll need to set your path to include the installation directory&#8217;s bin directory.  You should either make sure you don&#8217;t have <span class="caps">QTDIR</span> set in your environment, or set <span class="caps">QTDIR</span> to the installation path before running make install.  For example, if installing into /opt/qt5 (this assumes you are using bash; for csh-derived shells you&#8217;ll need to run setenv equivalents first):</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">PATH<span class="sy0">=/</span>opt<span class="sy0">/</span>qt5<span class="sy0">:</span>$PATH QTDIR<span class="sy0">=/</span>opt<span class="sy0">/</span>qt5 make install</div></li>
</ol></div></p>

	<a name="0647f0776aed243f58bfec4dd81de863"></a>	<h2>Cleaning</h2>

	<p>To <strong>really</strong> get a clean tree use:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">git submodule <span class="kw2">foreach</span> <span class="sy0">--</span>recursive <span class="st0">'git clean -dfx'</span></div></li>
</ol></div></p>

	<p>since make confclean no longer works from the top-level of the repo.</p>

	<a name="1dbe9e8c128d0b3cafbeaef20b9082cf"></a>	<h2>Getting updates</h2>

	<p>To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">git pull</div></li>
<li class="li1"><div class="de1">git submodule update <span class="sy0">--</span>recursive</div></li>
</ol></div></p>

	<ul>
		<li><strong>Warning:</strong> git submodule update does a hard reset on submodules, potentially getting rid of any local commits you&#8217;ve done! If the latter happened to you (and you haven&#8217;t been working with branches anyhow), git reflog is your friend &#8230;.</li>
	</ul>

	<a name="181b27e32ae791e987cb19fced190543"></a>	<h2>Using master branches in the submodules</h2>

	<p>By default the checkout will not contain the latest master branches of each individual submodule repository, but a combination of versions that are known to work together. If you want to get the absolute latest stuff you can do so on a per-module basis, e.g.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qtdeclarative</div></li>
<li class="li1"><div class="de1">git fetch</div></li>
<li class="li1"><div class="de1">git checkout master origin<span class="sy0">/</span>master</div></li>
</ol></div></p>

	<p>or use qt5_tool to update all repositories to master:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">.<span class="sy0">/</span>qtrepotools<span class="sy0">/</span>bin<span class="sy0">/</span>qt5_tool <span class="sy0">-</span>p</div></li>
</ol></div></p>

	<p>However, there&#8217;s a good chance that compilation will fail due to incompatible versions of submodules! You might want to ask other persons actively working on a module how to resolve these incompatibilities.</p>

	<a name="80b768b15c3693e345a436b9dc0ea36f"></a>	<h2>Issues</h2>

	<a name="858ba1c6abf9ee834612f32bace6fc04"></a>	<h3>configure fails with &#8220;No <span class="caps">QPA</span> platform plugin enabled!&#8221;</h3>

	<p>You should install the libxcb and it&#8217;s accompanying packages, see &#8216;Build Requirements&#8217;.</p>

	<a name="b2dd1bbeb4b3f043e6dfd4905a5850b6"></a>	<h3>qmlscene segfaults &#8220;Cannot create platform GL context, none of <span class="caps">GLX</span>, <span class="caps">EGL</span>, DRI2 is enabled&#8221;</h3>

	<p>Try installing the libx11-xcb-dev package:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">sudo aptitude install libx11<span class="sy0">-</span>xcb<span class="sy0">-</span>dev</div></li>
</ol></div></p>

	<p>afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.</p>

	<a name="09cf75f72c60cefc97faafa7a775eb12"></a>	<h3>qdeclarative doesn&#8217;t compile because of missing v8.lib (Windows)</h3>

	<p>Compiling v8 in qtbase requires Python. Make sure you have a python.exe in your &#37;<span class="caps">PATH</span>&#37;, go to qtjsbackend, run qmake &amp;&amp; nmake.</p>

	<a name="5fde07c989c8732b1f48c0acb8ce5dcd"></a>	<h3>WebKit doesn&#8217;t compile, missing <span class="caps">ICU</span></h3>

	<p>Currently there is no configure time check for <span class="caps">ICU</span>, so install it through the package manager through</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">yum search ICU</div></li>
</ol></div></p>

	<p>Or build it without webkit support by passing -no-webkit</p>

	<a name="6a8586788730cc7f6489adde4cbd4c6d"></a>	<h3>Debugging OpenGL issues (Windows)</h3>

	<p>Set the environment variable QT_LIGHTHOUSE_WINDOWS_VERBOSE=gl:1 and run the application with DebugView installed. The log will show the requested vs obtained OpenGL version. If the log tells you that it only has OpenGL 1.1, QML2 will not work. Note that qmlscene will not report errors about unsupported OpenGL versions.</p>

	<a name="9832a8a505d2bd3352d26e84e88d0218"></a>	<h2>Questions &amp; Comments</h2>

	<p>Please raise questions &amp; comments about this article in the forum : <a href="http://developer.qt.nokia.com/forums/viewthread/7018">http://developer.qt.nokia.com/forums/viewthread/7018</a></p>]]></description>
      <dc:subject>Building_Qt_5_from_Git</dc:subject>
      <dc:date>2012-02-22T21:25:07+00:00</dc:date>
    </item>

    <item>
      <title>How_to_locally_disable_qrc_in_QML</title>
      <link>http://developer.qt.nokia.com/wiki/How_to_locally_disable_qrc_in_QML</link>
      <guid>http://developer.qt.nokia.com/wiki/How_to_locally_disable_qrc_in_QML</guid>
      <description><![CDATA[<a name="9521e4734fa039e9f92c77f230377562"></a>	<h1> How to Locally Disable <span class="caps">QRC</span> in <span class="caps">QML</span></h1>

	<p>By default, when you load any file in <span class="caps">QML</span> using <span class="caps">QRC</span> (<a href="http://developer.qt.nokia.com/doc/qt-4.8/resources.html">Qt Resource System</a> <em>[developer.qt.nokia.com]</em>), all files down the hierarchy tree are loaded using resource system, too. This is nice and handy for most use cases, because it allows you to switch to <span class="caps">QRC</span> without big changes to the source code.</p>

	<p>But what if you are using resources, and suddenly need to load a non-qrc file? For example, in an app you are developing, a certain module, or game&#8217;s save file, can be provided by user at runtime, using relative path. Currently, <span class="caps">QML</span> will not allow that &#8211; once you&#8217;ve started using resources, the declarative engine loads all files using <span class="caps">QRC</span> scheme.</p>

	<p>I faced the same problem and found a pretty nice and easy solution: <span class="caps">QRC</span> can be locally disabled. It will not break anything &#8211; in fact, after turning the <span class="caps">QRC</span> scheme off, you can still load a file from resource system, and the <span class="caps">QML</span> engine will automatically reapply the scheme.</p>

	<p>Here&#8217;s what needs to be done (to make the example simple, I assume we need to disable <span class="caps">QRC</span> in a Loader element):
	<ol>
		<li>In C++, define a signal to be emitted before the new file is to be loaded, and a slot to receive the signal. Connect them together, and <a href="http://developer.qt.nokia.com/doc/qt-4.8/qtbinding.html#embedding-c-objects-into-qml-components">add as context properties to your <span class="caps">QML</span></a> <em>[developer.qt.nokia.com]</em>. In this case, I&#8217;ll use &#8220;void disableQrcSignal(QObject *object);&#8221; as signal, and &#8220;void disableQrcSlot(QObject *object);&#8221; as slot</li>
		<li>Before you change &#8220;source&#8221; property of your Loader, send &#8220;disableQrcSignal(loaderId)&#8221; signal.</li>
	</ol></p>

	<p>Here&#8217;s a snippet (I&#8217;m using a global property, fileToLoad, to store the path):</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">Loader <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; id<span class="sy0">:</span> loader</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; source<span class="sy0">:</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; disableQrcUse<span class="br0">&#40;</span>loader<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> fileToLoad<span class="sy0">;</span> <span class="co1">// A relative path or QRC path!</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div><br />
This ensures that <span class="caps">QRC</span> is disabled before you start loading the file. Of course, it can also be made in other ways.</p>

	<p>In your disableQrcSlot() body, use this code:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw4">void</span> MyClass<span class="sy0">::</span><span class="me2">disableQrcSlot</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span>object<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// This assumes that QDeclarativeEngine is available</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; QDeclarativeContext <span class="sy0">*</span>context <span class="sy0">=</span> engine<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me3">contextForObject</span><span class="br0">&#40;</span>object<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="co1">// This line clears QRC scheme from object's context</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; context<span class="sy0">-&gt;</span><span class="me3">setBaseUrl</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QUrl.html"><span class="kw5">QUrl</span></a><span class="sy0">::</span><span class="me2">fromLocalFile</span><span class="br0">&#40;</span><span class="st0">&quot;&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>And that&#8217;s it! Now you can use this signal in any place in your code to temporarily disable <span class="caps">QRC</span> loading.</p>]]></description>
      <dc:subject>How_to_locally_disable_qrc_in_QML</dc:subject>
      <dc:date>2012-02-22T21:20:11+00:00</dc:date>
    </item>

    <item>
      <title>Qt_Creator_Plug in_Gallery</title>
      <link>http://developer.qt.nokia.com/wiki/Qt_Creator_Plug&#45;in_Gallery</link>
      <guid>http://developer.qt.nokia.com/wiki/Qt_Creator_Plug&#45;in_Gallery</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#6035b088adee3db5cd90e4a526317770">Extend Qt Creator</a></li>
<li><a href="#d450202a2da1fecf6d6d68295f2a272d">Contributing plugins</a></li>
<li><a href="#ffc3b25622f8e05a3a9a604e7b37de4d">Qt Creator Plug-in Gallery</a><ul>
<li><a href="#a88d027e2556a1ceeb6b627935220a0c">Class browser</a></li>
<li><a href="#a4d26d451e644b2e5bdd9aeaae1b0f02">Doxygen generator</a></li>
<li><a href="#debcecb33e51a748d9e06b0f6b15e74e">CppHelper</a></li>
<li><a href="#a0e3947a02661e2385e4b76ab1b12f4d">Macros</a></li>
<li><a href="#13ade65758cc2fa119e4d28ff0649bb5">Emacs keys</a></li>
<li><a href="#d79c43d327e90d9eab28dadf4cd3c263">autotools (MERGED)</a></li>
<li><a href="#418a0a6ef7a69d0dcd67044df516080c">UML tool</a></li>
<li><a href="#d3918fd60b4295760407a8884a27d34a">Remote Compiler</a></li>
<li><a href="#64e697e2f503c968b31becd21ee08c00">Profiling plugin</a></li>
<li><a href="#7c516c8b0ed76620d7e6091b1d60d846">compile errors inline</a></li>
<li><a href="#d9949b716c2f203b62963d321ae59195">display todo / fixme etc. comments</a></li>
<li><a href="#880eed7059fca4a4c1fca99f9bb3a65b">TODO plugin</a></li>
<li><a href="#b5db383af80500c9dde7e42dd980ba70">AStyle plugin</a></li>
<li><a href="#1e1c536562bb5f34d20fb11cb1515e7c">WebRunTime Plugin</a></li>
<li><a href="#bc699d2d2b0f356167dd35c7c3c5b199">Bazaar plugin</a></li>
<li><a href="#153159b1ef9ba78a873febef25612411">OpenPilot</a></li>
<li><a href="#c6ebd48bf163dcdd867dfccc06403930">Mylyn Plugin</a></li>
<li><a href="#006a8d1805cdcd77e83c233e29390a36">CruiseControl Monitor Plugin</a></li>
<li><a href="#f01a6233c7686540c3002aea3a8411db">XmlTree Plugin</a></li>
<li><a href="#ca8d5bd68d8667e9b835722adf963eb4">Static Code Quality Plugin</a></li>
<li><a href="#551027aa1f538ebe8ba1c8d0377d8787">CodeBlocks Project Manager Plugin</a></li>
<li><a href="#fe72b484d2782f0827ec979ccfb8b7a1">Google Native Client Toolchain Plugin</a></li>
<li><a href="#0550dbc4737dddc1298e8b6bfb49761d">Premake Project Manager Plugin</a></li></ul>
</li>
<li><a href="#2b52bbf2253abd0221043775f0516b50">External documentation</a></li></ul>
</div>

	<a name="6035b088adee3db5cd90e4a526317770"></a>	<h1>Extend Qt Creator</h1>

	<p>Even though Qt Creator and Eclipse are different tools written in different programming languages, they still share the approach of adding all the functionality by plugins. So, from that point of view Qt Creator and Eclipse can be seen more as plugin frameworks instead of <span class="caps">IDE</span>s.</p>

	<p>A plugin implements certain extension points but at the same time can also define new extension points. And that’s where Qt Creator and Eclipse differentiate. </p>

	<p>In Eclipse, the extension points are usually defined as soon as the plugin is implemented meaning that those interfaces are often best guesses based on one example extension if at all. This may easily result in unnecessary extension in the first place or too inflexible or limited interfaces for more real world use cases. </p>

	<p>Qt Creator takes another approach. In most cases plugins do not define extension points immediately, so it’s always treated as a  leave. For the first use case which requires an extension we still recommend to put the new functionality into the existing plugin implementation. Once a second or third use case comes up we start refactoring the original plugin and define the extension points. Obviously, this is not a 100% guarantee that those interfaces are perfect and cover all future needs, but it’s definitely better than basing the extension point on only one example or even pure guesses.</p>

	<a name="d450202a2da1fecf6d6d68295f2a272d"></a>	<h1>Contributing plugins</h1>

	<p>Please check <a href="http://developer.qt.nokia.com/wiki/Qt-Creator-Plug-in-Contribution-Guide">Qt Creator Plug in Contribution Guide</a> when considering contributing a plugin to Qt Creator.</p>

	<a name="ffc3b25622f8e05a3a9a604e7b37de4d"></a>	<h1>Qt Creator Plug-in Gallery</h1>

	<a name="a88d027e2556a1ceeb6b627935220a0c"></a>	<h2>Class browser</h2>

	<p><a href="http://www.cppblog.com/visualfc/archive/2010/01/21/106142.html">site</a> <em>[cppblog.com]</em></p>

	<a name="a4d26d451e644b2e5bdd9aeaae1b0f02"></a>	<h2>Doxygen generator</h2>

	<p>generates doxygen comments from source code<br />
<a href="http://dev.kofee.org/projects/qtcreator-doxygen/">site</a> <em>[dev.kofee.org]</em></p>

	<a name="debcecb33e51a748d9e06b0f6b15e74e"></a>	<h2>CppHelper</h2>

	<p>generates implementation-stubs (discontinued, replaced by refactoring action in Qt Creator 2.1)<br />
<a href="http://gitorious.org/creator-plugins">site</a> <em>[gitorious.org]</em></p>

	<a name="a0e3947a02661e2385e4b76ab1b12f4d"></a>	<h2>Macros</h2>

	<p>record action-sequence and playback status (merged, first version shipping it is Qt Creator 2.2)<br />
<a href="http://gitorious.org/creator-plugins">site</a> <em>[gitorious.org]</em></p>

	<a name="13ade65758cc2fa119e4d28ff0649bb5"></a>	<h2>Emacs keys</h2>

	<p>Emacs-style keybindings, alike &#8220;FakeVim&#8221;<br />
<a href="http://github.com/fberger/emacskeys">site</a> <em>[github.com]</em></p>

	<a name="d79c43d327e90d9eab28dadf4cd3c263"></a>	<h2>autotools (<span class="caps">MERGED</span>)</h2>

	<p>Autotool support for Creator<br />
<a href="http://www.gitorious.org/qtcreator-autotools-plugin">site</a> <em>[gitorious.org]</em>&#8221;</p>

	<p>Was merged into Qt Creator 2.4.</p>

	<a name="418a0a6ef7a69d0dcd67044df516080c"></a>	<h2><span class="caps">UML</span> tool</h2>

	<p><a href="http://vakken.groept.be/Vakken/MastersThesis0910/3230.pdf">doc</a> <em>[vakken.groept.be]</em></p>

	<a name="d3918fd60b4295760407a8884a27d34a"></a>	<h2>Remote Compiler</h2>

	<p>forum.nokia available in Nokia Qt <span class="caps">SDK</span></p>

	<a name="64e697e2f503c968b31becd21ee08c00"></a>	<h2>Profiling plugin</h2>

	<p>(oprofile / linux based)<br />
<a href="http://qt.gitorious.org/+symbio-profiler/qt-creator/qt-creator-profiler">site</a> <em>[qt.gitorious.org]</em></p>

	<a name="7c516c8b0ed76620d7e6091b1d60d846"></a>	<h2>compile errors inline</h2>

	<p>display compile warnings and errors (tasks) inline<br />
<a href="http://lists.qt.nokia.com/pipermail/qt-creator/2010-June/007084.html">announcement</a> <em>[lists.qt.nokia.com]</em>, <a href="http://lists.qt.nokia.com/pipermail/qt-creator/attachments/20100621/2d79c6cf/attachment.png">screenshot</a> <em>[lists.qt.nokia.com]</em></p>

	<a name="d9949b716c2f203b62963d321ae59195"></a>	<h2>display todo / fixme etc. comments</h2>

	<p>Display comments in the form of //todo bla bla in the build issues tab.<br />
The keywords that introduce the comments are configurable.<br />
<a href="http://lists.qt.nokia.com/pipermail/qt-creator/2010-July/007218.html">announcement</a> <em>[lists.qt.nokia.com]</em>, <a href="http://lists.qt.nokia.com/pipermail/qt-creator/attachments/20100709/46893085/attachment.png">screenshot</a> <em>[lists.qt.nokia.com]</em></p>

	<a name="880eed7059fca4a4c1fca99f9bb3a65b"></a>	<h2><span class="caps">TODO</span> plugin</h2>

	<p>This plugin add pane with list all <span class="caps">TODO</span>, <span class="caps">FIXME</span>, etc. <br />
In current version available:
	<ul>
		<li>Plugin settings</li>
		<li>Task window or Todo pane output selector</li>
		<li>Scanning all file in project or only current file selector</li>
		<li>Keywords editor</li>
		<li>Locale support</li>
	</ul></p>

	<p><a href="http://gitorious.org/qt-creator-todo-plugin">Download source</a> <em>[gitorious.org]</em><br />
<a href="http://dl.yarlug.org/misc/todoplugin/todoplugin.png">Screenshot</a> <em>[dl.yarlug.org]</em></p>

	<a name="b5db383af80500c9dde7e42dd980ba70"></a>	<h2>AStyle plugin</h2>

	<p>Full featured code pretty printer plugin using astyle<br />
<a href="http://astyleplugin.berlios.de">site</a> <em>[astyleplugin.berlios.de]</em></p>

	<a name="1e1c536562bb5f34d20fb11cb1515e7c"></a>	<h2>WebRunTime Plugin</h2>

	<p>Support for developing web based applications. Only a video of the plugin in action. <br />
Status: unknown<br />
<a href="http://www.youtube.com/watch?v=bXBE0DZmonY">video</a> <em>[youtube.com]</em></p>

	<a name="bc699d2d2b0f356167dd35c7c3c5b199"></a>	<h2>Bazaar plugin</h2>

	<p>A plugin adding support for the bazaar version control system. Status: merged (first version shipping it is Qt Creator 2.2)<br />
<a href="https://blueprints.launchpad.net/bzr/+spec/bazaar-plugin-for-qt-creator-ide">site</a> <em>[blueprints.launchpad.net]</em></p>

	<a name="153159b1ef9ba78a873febef25612411"></a>	<h2>OpenPilot</h2>

	<p>A plugin using Qt Creator as a plugin manager only, embedding a map. <br />
Status: unknown<br />
<a href="http://openpilot.org/GCS_Plugin_Development">site</a> <em>[openpilot.org]</em></p>

	<a name="c6ebd48bf163dcdd867dfccc06403930"></a>	<h2>Mylyn Plugin</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Mylyn">Mylyn</a> is a application lifecycle management plugin, inspired by an eclipse plugin of the same name. Status: unknown, no changes for a couple of month now.<br />
<a href="http://github.com/NoobSaibot/qt-creator/tree/mylyn">site</a> <em>[github.com]</em></p>

	<a name="006a8d1805cdcd77e83c233e29390a36"></a>	<h2>CruiseControl Monitor Plugin</h2>

	<p>A simple plugin for monitoring a CruiseControl continuous integration server<br />
<a href="http://code.google.com/p/qtcreator-cc-plugin">site</a> <em>[code.google.com]</em></p>

	<a name="f01a6233c7686540c3002aea3a8411db"></a>	<h2>XmlTree Plugin</h2>

	<p>A plugin for reading and editing xml files as tree.<br />
<a href="http://gitorious.org/qt-creator-xml-tree-plugin">site</a> <em>[gitorious.org]</em></p>

	<a name="ca8d5bd68d8667e9b835722adf963eb4"></a>	<h2>Static Code Quality Plugin</h2>

	<p>A plugin for performing static code quality tests. Based on Krazy and making use of Qt Script and the cpp parser that comes with Qt Creator. Currently in a development state and not completely ready for use.<br />
<a href="http://gitorious.org/qt-creator-static-code-quality-plugin/pages/Home">site</a> <em>[gitorious.org]</em></p>

	<a name="551027aa1f538ebe8ba1c8d0377d8787"></a>	<h2>CodeBlocks Project Manager Plugin</h2>

	<p>This plugin can read Codeblocks .workspace project files. It reads the projects hierarchy and parses the individual .cbp project files to extract the source and header files and the build targets. Using commandline Codeblocks it allows you to (re)build your workspace. Also the build output is parsed(gcc and msvc supported).<br />
<a href="https://gitorious.org/codeblockprojectmanager">site</a> <em>[gitorious.org]</em></p>

	<a name="fe72b484d2782f0827ec979ccfb8b7a1"></a>	<h2>Google Native Client Toolchain Plugin</h2>

	<p>Adds the Chrome browser as a target. For use with the NaCl port of Qt.<br />
<a href="http://developer.qt.nokia.com/wiki/Qt_for_Google_Native_Client">site</a> <em>[developer.qt.nokia.com]</em></p>

	<a name="0550dbc4737dddc1298e8b6bfb49761d"></a>	<h2>Premake Project Manager Plugin</h2>

	<p>This plugin adds support of <a href="http://industriousone.com/premake">Premake</a> <em>[industriousone.com]</em> build configuration tool into Qt Creator.<br />
<a href="https://gitorious.org/qtcreator-premake-plugin">site</a> <em>[gitorious.org]</em></p>

	<a name="2b52bbf2253abd0221043775f0516b50"></a>	<h1>External documentation</h1>

	<p>You can display external documentation in the Qt Creator Help mode. For more information, see the <a href="http://doc.qt.nokia.com/qtcreator-snapshot/creator-help.html#adding-external-documentation">Qt Creator Manual</a> <em>[doc.qt.nokia.com]</em>.</p>

	<p>See <a href="https://developer.qt.nokia.com/wiki/Qt_Creator_Documentation_Gallery">Qt Creator Documentation Gallery</a> <em>[developer.qt.nokia.com]</em> for a list of them.</p>]]></description>
      <dc:subject>Qt_Creator_Plug in_Gallery</dc:subject>
      <dc:date>2012-02-21T13:43:20+00:00</dc:date>
    </item>

    <item>
      <title>QML Dynamic Objects</title>
      <link>http://developer.qt.nokia.com/wiki/QML&#45;Dynamic&#45;Objects</link>
      <guid>http://developer.qt.nokia.com/wiki/QML&#45;Dynamic&#45;Objects</guid>
      <description><![CDATA[<p><strong>English</strong><br />
<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#52718d08f351cddf70f7edc5f8d76e2d">QML Dynamic Objects</a><ul>
<li><a href="#0b79795d3efc95b9976c7c5b933afce2">Introduction</a></li>
<li><a href="#005b4b3cb1cee81cbe80e3bd623ab86c">Creation of Dynamic QML Objects</a></li>
<li><a href="#a7e2d8f6c1eba00e8556e6dca88157cd">Communication with Dynamic Objects</a></li>
<li><a href="#614e65c3a40e3f6920010ef863f03abd">Dynamic Objects Behavior – Nested Objects</a></li>
<li><a href="#46e66670ede41b4662f29afe3e6cef43">Destroying Dynamic Objects</a></li></ul>
</li></ul>
</div></p>

	<a name="52718d08f351cddf70f7edc5f8d76e2d"></a>	<h1><span class="caps">QML</span> Dynamic Objects</h1>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h2>Introduction</h2>

	<p><span class="caps">QML</span> has a very reach set of techniques for visualization control like visual objects appearing/disappearing on the scene. We mean dynamic effects which could be controlled programmatically. These techniques could be classified in three groups. The techniques from the first group control a <span class="caps">QML</span> object property to hide and/or render a visual object. For example, <em>opacity</em> property is very often used by developers and as you know it serves as a mirror to visual state of an item.  Another useful properties are <em>visible, z, color:transparent</em>. The second group mechanisms apply some transformations to objects – moving of an object off the screen (assign negative values to <em>x,y</em> coordinates), transforming geometrical object shape. For instance, we may control object visualization through <em>width</em> and <em>height</em> properties. Have a look at the techniques groups illustrations bellow:<br />
First and second group<br />
<img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/overlapping.jpg" alt="" /></p>

	<p>Third group<br />
<img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/Loader.jpg" alt="" /></p>

	<p>The next snippet illustrates how <em>width</em> and <em>height</em> properties could be used to control visibility:</p>

	<p><em>dynamicWidth.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>top</div></li>
<li class="li1"><div class="de1">&nbsp; <span class="co1">// &nbsp;width: 360</span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="co1">// &nbsp;height: 360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>control</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span><span class="nu0">30</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">30</span><span class="sy0">;</span>color<span class="sy0">:</span><span class="st0">&quot;blue&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top.<span class="me1">width</span><span class="sy0">=</span><span class="nu0">100</span><span class="sy0">;</span> top.<span class="me1">height</span><span class="sy0">=</span><span class="nu0">100</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="co1">//end Rectangle control</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="co1">// end Item </span></div></li>
</ol></div></p>

	<p>You guessed already that top rectangle is constructed when <span class="caps">QML</span> file is loaded, but not visualized. It is because its <em>width</em> and <em>height</em> properties are not defined. We determine them later in <em>MouseArea</em> script block.</p>

	<p>The techniques of the first and second groups do not manage computer memory at all – the hidden objects are kept stored in memory. This could be considered as a plus because the hidden objects are easily accessible through their <em>IDs</em>.</p>

	<p>The third group includes mechanisms based on dynamic loading of <span class="caps">QML</span> objects. These are <span class="caps">QML</span> constructs <em>Loader</em> and dynamic creation of objects. This article discusses <a href="http://doc.qt.nokia.com/4.7/qdeclarativedynamicobjects.html">dynamic creation of objects</a> <em>[doc.qt.nokia.com]</em>. More information about <em>Loader</em> utilization is <a href="http://developer.qt.nokia.com/wiki/QML-Application-Structuring-Approaches">here</a> <em>[developer.qt.nokia.com]</em>. </p>

	<a name="005b4b3cb1cee81cbe80e3bd623ab86c"></a>	<h2>Creation of Dynamic <span class="caps">QML</span> Objects</h2>

	<p>The process of dynamic creating of <span class="caps">QML</span> objects consists of two steps. Firstly, an object is created and secondly newly created object is loaded. The process is performed in a JavaScript context only. In other words, we have some JavaScript methods, which could be invoked in a script block. </p>

	<p>The dynamic object is normally formatted as a <span class="caps">QML</span> computer file or we want to get it as a string. Our considerations are limited to the second case. For this case steps of creating and loading are combined in one step. The signature of the respective JavaScript method is as <a href="http://doc.qt.nokia.com/4.7/qdeclarativedynamicobjects.html#creating-an-object-from-a-string-of-qml">follows</a> <em>[doc.qt.nokia.com]</em>:</p>

 <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span>QML string<span class="sy0">,</span> parent ID<span class="sy0">,</span> filename<span class="br0">&#41;</span></div></li>
</ol></div>

	<p>The first argument in the method invocation is a string formatted as a <span class="caps">QML</span> file, for example:</p>

                 <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp;‘Import QtQuick <span class="nu16">1.1</span><span class="sy0">;</span> Rectangle <span class="br0">&#123;</span>width<span class="sy0">:</span><span class="nu0">100</span><span class="sy0">;</span> height<span class="sy0">:</span><span class="nu0">100</span><span class="sy0">;</span> color<span class="sy0">:</span>”blue”<span class="br0">&#125;</span>’</div></li>
</ol></div>

	<p>We use single quotes for the <span class="caps">QML</span> string to avoid conflict with double quotes in color property definition. </p>

	<p>The second argument is the <em>ID</em> of <span class="caps">QML</span> item in which context the new object is created and loaded. That means that newly created object has as parent this context item. In invocation the context item <em>ID</em> is supplied as a variable name (no quotes are needed). </p>

	<p>The third argument is a string used as a file name in error reporting in Qt <span class="caps">IDE</span>. For example if an error is encountered in loaded <span class="caps">QML</span> string it is reported as one in the file with <em>filename</em> name. In invocation <em>filename</em> as a string has to be surrounded in double quotes.</p>

	<p>The function <em>createQmlObject()</em> is a method of the global <a href="http://doc.qt.nokia.com/4.7/qml-qt.html#createQmlObject-method"><span class="caps">QML</span> Qt object</a> <em>[doc.qt.nokia.com]</em>.</p>

	<p>Formally it is described as:</p>

 <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">object <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">createQmlObject</span> <span class="br0">&#40;</span> string qml<span class="sy0">,</span> object parent<span class="sy0">,</span> string filepath<span class="br0">&#41;</span></div></li>
</ol></div>

	<p>If you are tempted to use a <em>Loader</em> element from the <span class="caps">QML</span> string it will probably not work. It is because loading of an external file needs some time, but the method <em>createQmlObject()</em> returns not waiting for such operations. Here is a complete example of <em>createQmlObject()</em> method utilization:</p>

	<p><em>dynamicObject.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">&nbsp;Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;width<span class="sy0">:</span> <span class="nu0">500</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">100</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>second<span class="sy0">;</span> width<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">70</span><span class="sy0">;</span>color<span class="sy0">:</span><span class="st0">'green'</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span>var dynamicObject <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">'import QtQuick 1.1;Rectangle&#123;id:sample;width:40; height:40;color:&quot;blue&quot;;&#125;'</span><span class="sy0">,</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; container<span class="sy0">,</span><span class="st0">'firstObject'</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="co1">//end second</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;MouseArea <span class="br0">&#123;</span>id<span class="sy0">:</span>mouse1</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; var anotherObject <span class="sy0">=</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">'import QtQuick 1.1;Rectangle&#123;id:example;width:40; height:40;x:80;y:40;color:&quot;pink&quot;;&#125;'</span><span class="sy0">,</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; container<span class="sy0">,</span><span class="st0">'secondObject'</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="co1">//end onClicked</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><span class="co1">//end mouse1</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Practically it is inconvenient to supply a long <span class="caps">QML</span> string in <em>createQmlObject()</em> call. We could define a string property and assign to it <span class="caps">QML</span> string as property value. This is demonstrated in the following example:</p>

	<p><em>dynamicObjectTop.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;width<span class="sy0">:</span> <span class="nu0">500</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">200</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;property string test<span class="sy0">:</span><span class="st0">&quot;import QtQuick 1.1;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; Rectangle &#123;id:abc; color:<span class="es1">\&quot;</span>red<span class="es1">\&quot;</span>; width: 40; height: 20;x:100;y:50&#125;&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>second<span class="sy0">;</span> width<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">70</span><span class="sy0">;</span>color<span class="sy0">:</span><span class="st0">'green'</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var dynamicObject <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span>test<span class="sy0">,</span>container<span class="sy0">,</span><span class="st0">'firstObject'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="co1">//end second</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<a name="a7e2d8f6c1eba00e8556e6dca88157cd"></a>	<h2>Communication with Dynamic Objects</h2>

	<p>The dynamically created <span class="caps">QML</span> object is not accessible through its <em>ID</em>. We need other mechanisms for communication with dynamic objects and these are signals and <span class="caps">QML</span> signal objects <em>connect ()</em> method. By communication we mean exchange of information between the caller (main <span class="caps">QML</span> file) and the callee (dynamically created <span class="caps">QML</span> file) and in both directions.</p>

	<p>The next snippet shows that a property defined at the caller top level is visible (directly accessible) in the <span class="caps">QML</span> dynamic object:</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/property.jpg" alt="" /></p>

	<p><em>dynamicObjectProperty.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;width<span class="sy0">:</span> <span class="nu0">500</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">200</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;property <span class="kw4">bool</span> caller<span class="sy0">:</span><span class="kw2">false</span> &nbsp;<span class="co1">//This property is visible in the dynamic object</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;property string test<span class="sy0">:</span><span class="st0">&quot;import QtQuick 1.1;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; Rectangle &#123;id:abc; color:<span class="es1">\&quot;</span>red<span class="es1">\&quot;</span>; width: 40; height: 20;x:100;y:50</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; Component.onCompleted:</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;&#123;caller=true; console.log('New value to the property caller was assigned')&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &#125;&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>second<span class="sy0">;</span> width<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">70</span><span class="sy0">;</span>color<span class="sy0">:</span><span class="st0">'green'</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var dynamicObject <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span>test<span class="sy0">,</span>container<span class="sy0">,</span><span class="st0">'firstObject'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.<span class="kw3">log</span><span class="br0">&#40;</span><span class="st0">&quot;The value of caller was changed in the dynamic object&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="co1">//end second</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>In case we want to pass some information from <span class="caps">QML</span> string to the main file we define a signal, then connect it to a JavaScript method defined in the main <span class="caps">QML</span> file and finally emit the signal (in <span class="caps">QML</span> string):</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/signal.jpg" alt="" /></p>

	<p><em>dynamicObjectConnect.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;width<span class="sy0">:</span> <span class="nu0">500</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">200</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;<span class="kw4">signal</span> forward <span class="co1">//This signal activates fun2() defined in QML string</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;onForward<span class="sy0">:</span>console.<span class="kw3">log</span><span class="br0">&#40;</span><span class="st0">&quot;forward signal is emitted in main QML&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>dummy</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; forward<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;function fun1<span class="br0">&#40;</span>argument1<span class="br0">&#41;</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;console.<span class="kw3">log</span><span class="br0">&#40;</span><span class="st0">&quot;A function fun1()in the main QML file is invoked&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;console.<span class="kw3">log</span><span class="br0">&#40;</span><span class="st0">&quot;Returned parameter from the QML string = &quot;</span><span class="sy0">,</span> argument1<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;property string test<span class="sy0">:</span><span class="st0">&quot;import QtQuick 1.1;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; Rectangle &#123;id:abc;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; property string fromCallee:'This value is send signal argument'</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; //Signal send when emitted activates fun1() defined in main QML</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; signal send(string pass);</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; onSend:&#123;console.log('Signal send has been emitted');&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; color:<span class="es1">\&quot;</span>red<span class="es1">\&quot;</span>; width: 40; height: 20;x:100;y:50</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; Component.onCompleted:&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send.connect(fun1);send(fromCallee);forward.connect(fun2);</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &#125;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; function fun2()&#123;console.log('The function fun2() is activated from main QML')&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>second<span class="sy0">;</span> width<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">70</span><span class="sy0">;</span>color<span class="sy0">:</span><span class="st0">&quot;green&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var dynamicObject <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span>test<span class="sy0">,</span>container<span class="sy0">,</span><span class="st0">'firstObject'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span> <span class="co1">//end second</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span> </div></li>
</ol></div>  </p>

	<p>In the <span class="caps">QML</span> string we define the signal <em>send</em>, which invokes function <em>fun1()</em> defined in main <span class="caps">QML</span>. A parameter is passed also. And vice versa: in the main <span class="caps">QML</span> the signal <em>forward</em> is defined and emitted. It calls function <em>fun2()</em> defined in <span class="caps">QML</span> string.</p>

	<a name="614e65c3a40e3f6920010ef863f03abd"></a>	<h2>Dynamic Objects Behavior – Nested Objects</h2>

	<p>Let us create an application with the following functionality:<br />
1. The user enters some text in a <span class="caps">QML</span> <em>TextInput</em> element;<br />
2. The entered text is displayed in a window;<br />
3. The user is asked to confirm the entered text in a dialog window;</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/input.jpg" alt="" /></p>

	<p>The new point here is that from a dynamic object we want to create and load a next dynamic object. </p>

	<p><em>dynamicUseCase.qml</em><br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;width<span class="sy0">:</span> <span class="nu0">550</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">500</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;property string test<span class="sy0">:</span><span class="st0">&quot;import QtQuick 1.1;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; Rectangle &#123;id:abc;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;color:<span class="es1">\&quot;</span>lightsteelblue<span class="es1">\&quot;</span>; width: 200; height: 100;x:origin.x;y:origin.y+50;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;Text &#123;id:data;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:abc.width; height:abc.height;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// &nbsp;width:200;height:40;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text:input.text</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 'Your input is echoed here. Multiline text is supported.';</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wrapMode:Text.WordWrap;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;MouseArea &#123;id:callNested;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchors.fill:parent;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onClicked:&#123;var nextDynamic=Qt.createQmlObject(another,</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;container,'NextObject');</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; property string another:<span class="es1">\&quot;</span>import QtQuick 1.0;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;Rectangle&#123;id:nested;x:abc.x+220;y:abc.y;width:180;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height:40;color:'pink';</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text &#123;id:dialog;</span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:nested.width; height:nested.height;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text:'Do you accept entered data?'</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="st0"> &nbsp; &nbsp; <span class="es1">\&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="st0"> &nbsp; &nbsp; &#125;&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;Rectangle<span class="br0">&#123;</span>id<span class="sy0">:</span>origin</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width<span class="sy0">:</span><span class="nu0">300</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">30</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">100</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color<span class="sy0">:</span><span class="st0">&quot;lightblue&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;TextInput <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;id<span class="sy0">:</span>input</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x<span class="sy0">:</span>origin.<span class="me1">x</span><span class="sy0">+</span><span class="nu0">5</span><span class="sy0">;</span>y<span class="sy0">:</span>origin.<span class="me1">y</span><span class="sy0">+</span><span class="nu0">5</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;text<span class="sy0">:</span><span class="st0">&quot;Enter your text here&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onAccepted<span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dynamicObject <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">createQmlObject</span><span class="br0">&#40;</span>test<span class="sy0">,</span>container<span class="sy0">,</span><span class="st0">&quot;First Dynamic Object&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &nbsp; &nbsp;release(dynamicObject);</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="coMULTI">/***********************************************************************</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">//This section experiments with destroy() method</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">//Uncomment this section and call to release()in onAccepted script block</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="coMULTI">&nbsp; &nbsp; &nbsp;function release(objectToDelete)&#123;</span></div></li>
<li class="li2"><div class="de2"><span class="coMULTI">&nbsp; &nbsp; &nbsp;console.log(&quot;A dynamic object is deleted&quot;);</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;objectToDelete.destroy(9000);</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">&nbsp; &nbsp; &nbsp;&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">***********************************************************************/</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Some fragments of the above code need more explanation as they implement several rules of <span class="caps">QML</span> dynamic objects. In the first place, a dynamic <span class="caps">QML</span> object (rectangle <em>abc</em>) could contain a nested <span class="caps">QML</span> string – rectangle <em>nested</em>. As you see, the nested objects are in the same name space and this is used when we design the application layout – it is applied bounding of properties values. Moreover, the nested objects are executed in the context of the main <span class="caps">QML</span> file and they use properties from the main application space.</p>

	<p>To invoke the first dynamic object (rectangle <em>abc</em>) we use <em>onAccepted</em> signal generated after you enter the text in the <span class="caps">QML</span> <em>TextInput</em> field and hit <em>&lt;Enter&gt;.</em> The entered text is displayed in the rectangle <em>abc</em>. When you click on this rectangle, following <em>onClicked</em> signal, the nested object (rectangle <em>nested</em>) is rendered.</p>

	<a name="46e66670ede41b4662f29afe3e6cef43"></a>	<h2>Destroying Dynamic Objects</h2>

	<p>Analyzing the above code samples you probably asked yourself already how one could close dynamically created <span class="caps">QML</span> objects. To release (delete) a dynamically created <span class="caps">QML</span> object you could use <em>destroy()</em> method from within a JavaScript context. The method is called as member of newly created dynamic object. For example, considering our last code snippet, we call: <em>dynamicObject.destroy()</em>. The <em>destroy()</em> method has a parameter that supplies the time delay before the dynamic object will be destroyed. It is measured in milliseconds with a default value of zero.<br />
In the file <em>dynamicUseCase.qml</em> you have an commented section (at the file bottom) that experiments with <em>destroy()</em> method. Uncomment this section and call to <em>release()</em> function in <em>onAccepted</em> script block.</p>

	<p><em>Notes</em>:<br />
1. The <em>.qml</em> files used in the discussions above could be downloaded <a href="https://www.sugarsync.com/pf/D7703167_2142254_633511">here</a> <em>[sugarsync.com]</em>.<br />
2. The code samples were tested in a desktop environment – Windows 7, Qt Creator 2.4.1 (based on Qt 4.7.4).</p>]]></description>
      <dc:subject>QML Dynamic Objects</dc:subject>
      <dc:date>2012-02-21T11:30:54+00:00</dc:date>
    </item>

    <item>
      <title>Threads_Events_QObjects</title>
      <link>http://developer.qt.nokia.com/wiki/Threads_Events_QObjects</link>
      <guid>http://developer.qt.nokia.com/wiki/Threads_Events_QObjects</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#285a62c361be4793a6c10d04e3823a80">Threads, Events and QObjects</a><ul>
<li><a href="#35fd9ae083f893b0ba0e7c11f734c7a1">Warning: Beta Version</a></li></ul>
</li>
<li><a href="#0b79795d3efc95b9976c7c5b933afce2">Introduction</a><ul>
<li><a href="#ee68e5b99222bbc29a480fcb0d1d6ee2">Prerequisites</a></li></ul>
</li>
<li><a href="#e3189e3dc40b94d64bb90318c4c401cb">Events and the event loop</a><ul>
<li><a href="#6c678d88cb4b92f3adbd4d6182d6ea78">What requires a running event loop?</a></li>
<li><a href="#47bf77cab852bf395a980b572877aa84">Blocking the event loop</a></li>
<li><a href="#7494f2b4836907fc1c09311e3a0305e6">Forcing event dispatching</a></li></ul>
</li>
<li><a href="#06e458ba8f7f1c02207c32d3157ac217">Qt thread classes</a><ul>
<li><a href="#be502ae00ff1867ebe29398c0c9ec833">QThread</a></li>
<li><a href="#8493c32c6b5b4020e2d007b5ee4fcd09">QRunnable and QThreadPool</a></li>
<li><a href="#06a6e24fbdb7c79190b6572a617ae5f6">QtConcurrent</a></li>
<li><a href="#0161e3d40bdbea6ca6998c8c60165b33">Feature comparison</a></li></ul>
</li>
<li><a href="#64a093776750c691afdeb133a80f55e2">Threads and QObjects</a><ul>
<li><a href="#80c8e93605b398d5fd0833250323bc89">Per-thread event loop</a></li>
<li><a href="#913fb94dd61f1a62fc809f8d842c3afa">Signals and slots across threads</a></li>
<li><a href="#c61304cd8162519084c4baa3f01ef866">DOs and DON'Ts</a></li></ul>
</li>
<li><a href="#860bcdee4372c82ce0821a40857eb766">When should I use threads?</a><ul>
<li><a href="#922f8c2226485920d309b1de41bc8eb1">When you have to use a blocking API</a></li>
<li><a href="#fb9db77c23fc9e0a48452ff7250e43fc">When you want to scale with the number of CPUs</a></li>
<li><a href="#605fc5d1bdd8d9f08192df140937a7c7">When you don't want to be possibly blocked by others</a></li></ul>
</li>
<li><a href="#c2e33c61ced29e1eb1bee9a1671f202e">When shouldn't I use threads?</a><ul>
<li><a href="#92dd35cc61ffc41d02defdcef071856d">Timers</a></li>
<li><a href="#2b40afeff6025af55f25a6c7ea5ab3bc">Networking / state machines</a></li>
<li><a href="#72c9aabadf52900fbf3d4c1ff2b6008c">Jobs splittable in chunks</a></li></ul>
</li>
<li><a href="#fdc53ed8cc27daf8b62151825562a9a5">Some examples</a><ul>
<li><a href="#0205eacc79baf77a16ff08e24fbba67a">MD5 hash</a></li></ul>
</li>
<li><a href="#d95867deadfe690e40f42068d6b59df8">References</a></li></ul>
</div>

	<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Threads-Events-QObjects_Russian">Русский</a> <a href="http://developer.qt.nokia.com/wiki/Threads-Events-QObjects_Chinese">中文</a> </p>

	<a name="285a62c361be4793a6c10d04e3823a80"></a>	<h1>Threads, Events and QObjects</h1>

	<a name="35fd9ae083f893b0ba0e7c11f734c7a1"></a>	<h2>Warning: Beta Version</h2>

	<p>The article is almost done, but it needs a bit of polishing and some good examples. Any review or contribution is welcome! Discussion about this article happens <a href="http://developer.qt.nokia.com/forums/viewthread/2423/">in this thread</a> <em>[developer.qt.nokia.com]</em> .</p>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h1>Introduction</h1>

	<blockquote>
		<p>You&#8217;re doing it wrong. &#8212; Bradley T. Hughes</p>
	</blockquote>

	<p>One of the most popular topics on the <a href="irc://irc.freenode.net/#qt">#qt <span class="caps">IRC</span> channel</a> <em>[irc.freenode.net]</em> is threading: many people join the channel and ask how they should solve their problem with some code running in a different thread.</p>

	<p>Nine times out of ten, a quick inspection of their code shows that the biggest problem is the very fact they&#8217;re using threads in the first place, and they&#8217;re falling in one of the endless pitfalls of parallel programming.</p>

	<p>The ease of creating and running threads in Qt, combined with some lack of knowledge about programming styles (especially asynchronous network programming, combined with Qt&#8217;s signals and slots architecture) and/or habits developed when using other tookits or languages, usually leads to people shooting themselves in the foot. Moreover, threading support in Qt is a double-edged sword: while it makes it very simple for you to do multithread programming, it adds a certain number of features (especially when it comes to interaction with QObjects) you must be aware of.</p>

	<p>The purpose of this document is <strong>not</strong> to teach you how to use threads, do proper locking, exploit parallelism, nor write scalable programs; there are many good books about these topics; for instance, take a look to the recommended reading list <a href="http://doc.qt.nokia.com/latest/threads.html">on this page</a> <em>[doc.qt.nokia.com]</em>. Instead, this small article is meant to be a guide to introduce users to threading in Qt 4, in order to avoid the most common pitfalls and help them to develop code that is at the same time more robust and with a better structure.</p>

	<a name="ee68e5b99222bbc29a480fcb0d1d6ee2"></a>	<h2>Prerequisites</h2>

	<blockquote>
		<p>Think of it this way: threads are like salt, not like pasta.<br />
You like salt, I like salt, we all like salt. But we eat more pasta.<br />
&#8212; Larry McVoy</p>
	</blockquote>

	<p>Not being a general-purpose introduction to (threads) programming, we expect you to have some previous knowledge about:</p>

	<ul>
		<li>C++ basics (though most suggestions do apply to other languages as well);</li>
		<li>Qt basics: QObjects, signals and slots, event handling;</li>
		<li>what a thread is and what the relationships are between threads, processes and the operating system;</li>
		<li>how to start and stop a thread, and wait for it to finish, under (at least) one major operating system;</li>
		<li>how to use mutexes, semaphores and wait conditions to create thread-safe/reentrant functions, data structures, classes.</li>
	</ul>

	<p>In this document we&#8217;ll follow the Qt <a href="http://doc.qt.nokia.com/latest/threads-reentrancy.html">naming conventions</a> <em>[doc.qt.nokia.com]</em>, which are:</p>

	<ul>
		<li><strong>Reentrant</strong> A class is reentrant if it&#8217;s safe to use its instances from more than one thread, provided that at most one thread is accessing the same instance at the same time. A function is reentrant if it&#8217;s safe to invoke it from more than one thread at the same, provided that each invocation references unique data. In other words, this means that users of that class/function must <em>serialize</em> all accesses to instances/shared data by means of some <em>external locking mechanism</em>.</li>
		<li><strong>Thread-safe</strong> A class is thread-safe if it&#8217;s safe to use its instances from more than one thread at the same time. A function is thread-safe if it&#8217;s safe to invoke it from more than one thread at the same time even if the invocations reference shared data.</li>
	</ul>

	<a name="e3189e3dc40b94d64bb90318c4c401cb"></a>	<h1>Events and the event loop</h1>

	<p>Being an event-driven toolkit, events and event delivery play a central role in Qt architecture. In this article we&#8217;ll not give a comprehensive coverage about this topic; we&#8217;ll instead focus on some thread-related key concepts (see <a href="http://doc.qt.nokia.com/latest/eventsandfilters.html">here</a> <em>[doc.qt.nokia.com]</em> and <a href="http://doc.qt.nokia.com/qq/qq11-events.html">here</a> <em>[doc.qt.nokia.com]</em> for more information about the Qt event system). </p>

	<p>An <strong>event</strong> in Qt is an object which represents something interesting that happened; the main difference between an event and a signal is that events are <em>targeted</em> to a specific object in our application (which decides what to do with that event), while signals are emitted &#8220;in the wild&#8221;. From a code point of view, all events are instances of some subclass of <a href="http://doc.qt.nokia.com/latest/qevent.html">QEvent</a> <em>[doc.qt.nokia.com]</em>, and all QObject-derived classes can override the QObject::event() virtual method in order to handle events targeted to their instances.</p>

	<p>Events can be generated from both inside and outside the application; for instance:
	<ul>
		<li>QKeyEvent and QMouseEvent objects represent some kind of keyboard and mouse interaction, and they come from the window manager;</li>
		<li>QTimerEvent objects are sent to a QObject when one of its timers fires, and they (usually) come from the operating system;</li>
		<li>QChildEvent objects are sent to a QObject when a child is added or removed, and they come from inside your Qt application.</li>
	</ul></p>

	<p>The important thing about events is that they&#8217;re not delivered as soon as they&#8217;re generated; they&#8217;re instead queued up in an <strong>event queue</strong> and sent sometime later. The dispatcher itself loops around the event queue and sends queued events to their target objects, and therefore it is called the <strong>event loop</strong>. Conceptually, this is how an event loop looks (see the Qt Quarterly article linked above):<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw1">while</span> <span class="br0">&#40;</span>is_active<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="sy0">!</span>event_queue_is_empty<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; dispatch_next_event<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; wait_for_more_events<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>We enter Qt&#8217;s main event loop by running QCoreApplication::exec&#40;&#41;; this call blocks until QCoreApplication::exit() or QCoreApplication::quit() are called, terminating the loop.</p>

	<p>The &#8220;wait_for_more_events()&#8221; function blocks (that is, it&#8217;s not a busy wait) until some event is generated. If we think about it, all that can generate events at that point is some <em>external</em> source (dispatching for all internal events is now complete and there were no more pending events in the event queue to delivery). Therefore, the event loop can be woken up by:</p>

	<ul>
		<li>window manager activity (key/mouse presses, interaction with the windows, etc.);</li>
		<li>sockets activity (there&#8217;s some data available to read, or a socket is writable without blocking, there&#8217;s a new incoming connection, etc.);</li>
		<li>timers (i.e. a timer fired);</li>
		<li>events posted from other threads (see later).</li>
	</ul>

	<p>In a <span class="caps">UNIX</span>-like system, window manager activity (i.e. X11) is notified to applications via sockets (Unix Domain or <span class="caps">TCP</span>/IP), since clients use them to communicate with the X server. If we decide to implement cross-thread event posting with an internal socketpair(2), all that is left is being woken up by activity on:
	<ul>
		<li>sockets;</li>
		<li>timers;</li>
	</ul></p>

	<p>which is exactly what the <strong>select(2)</strong> system call does: it watches over a set of descriptors for activity <em>and</em> it times out (with a configurable timeout) if there&#8217;s no activity for a certain while. All Qt needs to do is converting what select returns into an object of the right QEvent subclass and queue it up in the event queue. Now you know what&#8217;s inside an event loop <span class="smiley">:)</span></p>

	<a name="6c678d88cb4b92f3adbd4d6182d6ea78"></a>	<h2>What requires a running event loop?</h2>

	<p>This isn&#8217;t an exhaustive list, but if you have the overall picture, you should be able to guess which classes require a running event loop.</p>

	<ul>
		<li><strong>Widgets painting and interaction</strong>: QWidget::paintEvent() will be called when delivering QPaintEvent objects, which are generated both by calling QWidget::update() (i.e. internally) or by the window manager (for instance, because a hidden window was shown). The same thing holds for all kinds of interaction (keyboard, mouse, etc.): the corresponding events will require an event loop to be dispatched.</li>
		<li><strong>Timers</strong>: long story short, they&#8217;re fired when select(2) or similar calls time out, therefore you need to let Qt do those calls for you by returning to the event loop.</li>
		<li><strong>Networking</strong>: all low-level Qt networking classes (QTcpSocket, QUdpSocket, QTcpServer, etc.) are asynchronous by design. When you call read(), they just return already available data; when you call write(), they schedule the writing for later. It&#8217;s only when you return to the event loop the actual reading/writing takes place. Notice that they do offer synchronous methods (the waitFor* family of methods), but their use is discouraged because they block the event loop while waiting. High-level classes, like QNetworkAccessManager, simply do not offer any synchronous <span class="caps">API</span> and require an event loop.</li>
	</ul>

	<a name="47bf77cab852bf395a980b572877aa84"></a>	<h2>Blocking the event loop</h2>

	<p>Before discussing why <strong>you should never ever block the event loop</strong>, let&#8217;s try to figure out what this &#8220;blocking&#8221; means. Suppose you have a Button widget which emits a signal when clicked; connected to this signal there&#8217;s a slot of our Worker object, which does a lot of work. After you click the button, the stack trace will look like this (the stack grows downwards):</p>

	<ol>
		<li>main(int, char **)</li>
		<li>QApplication::exec&#40;&#41;</li>
		<li>[&#8230;]</li>
		<li>QWidget::event(QEvent *)</li>
		<li>Button::mousePressEvent(QMouseEvent *)</li>
		<li>Button::clicked()</li>
		<li>[&#8230;]</li>
		<li>Worker::doWork()</li>
	</ol>

	<p>In main() we started the event loop, as usual, by calling QApplication::exec&#40;&#41; (line 2). The window manager sent us the mouse click, which was picked up by the Qt kernel, converted in a QMouseEvent and sent to our widget&#8217;s event() method (line 4) by QApplication::notify() (not shown here). Since Button didn&#8217;t override event(), the base class implementation (QWidget) is called. QWidget::event() detects the event is actually a mouse click and calls the specialized event handler, that is, Button::mousePressEvent() (line 5). We overrode this method to emit the Button::clicked() signal (line 6), which invokes the Worker::doWork slot of our worker object (line 7).</p>

	<p>While the worker is busy working, what&#8217;s the event loop doing? You should&#8217;ve guessed it: nothing! It dispatched the mouse press event and it&#8217;s blocked waiting for the event handler to return. We managed to <strong>block the event loop</strong>, which means that no event is sent any more, until we return from the doWork() slot, up the stack, to the event loop, and let it process pending events. </p>

	<p>With the event delivery stuck, <strong>widgets won&#8217;t update themselves</strong> (QPaintEvent objects will sit in the queue), <strong>no further interaction with widgets is possible</strong> (for the same reason), <strong>timers won&#8217;t fire</strong> and <strong>networking communications will slow down and stop</strong>. Moreover, many window managers will detect that your application is not handling events any more and <strong>tell the user that your application isn&#8217;t responding</strong>. That&#8217;s why is so important to quickly react to events and return to the event loop as soon as possible!</p>

	<a name="7494f2b4836907fc1c09311e3a0305e6"></a>	<h2>Forcing event dispatching</h2>

	<p>So, what do we do if we have a long task to run and don&#8217;t want to block the event loop? One possible answer is to move the task into another thread: in the next sections we&#8217;ll see how to do that. We also have the option to manually force the event loop to run, by (repeatedly) calling QCoreApplication::processEvents() inside our blocking task. QCoreApplication::processEvents() will process all the events in the event queue and return to the caller. </p>

	<p>Another available option we can use to forcibly reenter the event loop is the <a href="http://doc.qt.nokia.com/latest/qeventloop.html">QEventLoop</a> <em>[doc.qt.nokia.com]</em> class. By calling QEventLoop::exec&#40;&#41; we reenter the event loop, and we can connect signals to the QEventLoop::quit() slot to make it quit. For instance:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QNetworkAccessManager.html"><span class="kw5">QNetworkAccessManager</span></a> qnam<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QNetworkReply.html"><span class="kw5">QNetworkReply</span></a> <span class="sy0">*</span>reply <span class="sy0">=</span> qnam.<span class="me1">get</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QNetworkRequest.html"><span class="kw5">QNetworkRequest</span></a><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QUrl.html"><span class="kw5">QUrl</span></a><span class="br0">&#40;</span>...<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QEventLoop.html"><span class="kw5">QEventLoop</span></a> loop<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="kw2">connect</span><span class="br0">&#40;</span>reply<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>finished<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="sy0">&amp;</span>loop<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>quit<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">loop.<span class="me1">exec</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* reply has finished, use it */</span></div></li>
</ol></div></p>

	<p>QNetworkReply doesn&#8217;t offer a blocking <span class="caps">API</span> and requires an event loop to be running. We enter a local QEventLoop, and when the reply has finished, the local event loop quits.</p>

	<p>Be very careful when reentering the event loop &#8220;by other paths&#8221;: it can lead to unwanted recursions! Let&#8217;s go back to the Button example. If we call QCoreApplication::processEvents() inside the doWork() slot, and the user clicks again on the button, the doWork() slot will be invoked <strong>again</strong>:</p>

	<ol>
		<li>main(int, char **)</li>
		<li>QApplication::exec&#40;&#41;</li>
		<li>[&#8230;]</li>
		<li>QWidget::event(QEvent *)</li>
		<li>Button::mousePressEvent(QMouseEvent *)</li>
		<li>Button::clicked()</li>
		<li>[&#8230;]</li>
		<li>Worker::doWork() // <strong>first, inner invocation</strong></li>
		<li>QCoreApplication::processEvents() // <strong>we manually dispatch events and&#8230;</strong></li>
		<li>[&#8230;]</li>
		<li>QWidget::event(QEvent * ) // <strong>another mouse click is sent to the Button&#8230;</strong></li>
		<li>Button::mousePressEvent(QMouseEvent *)</li>
		<li>Button::clicked() // <strong>which emits clicked() again&#8230;</strong></li>
		<li>[&#8230;]</li>
		<li>Worker::doWork() // <strong><span class="caps">DANG</span>! we&#8217;ve recursed into our slot.</strong></li>
	</ol>

	<p>A quick and easy workaround for this is passing QEventLoop::ExcludeUserInputEvents to QCoreApplication::processEvents(), which tells the event loop to not dispatch any user input event (the events will simply stay in the queue). </p>

	<p>Luckily, the same thing does <strong>not</strong> apply to <strong>deletion events</strong> (the ones posted in the event queue by QObject::deleteLater&#40;&#41;). In fact, they are handled in a special way by Qt, and are processed only if the running event loop has a smaller degree of &#8220;nesting&#8221; (w.r.t. event loops) than the one where deleteLater was called. For instance:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span>object <span class="sy0">=</span> <span class="kw1">new</span> QObject<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">object<span class="sy0">-&gt;</span><span class="me3">deleteLater</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QDialog.html"><span class="kw5">QDialog</span></a> dialog<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">dialog.<span class="me1">exec</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p><strong>will not</strong> make object a dangling pointer (the event loop entered by QDialog::exec&#40;&#41; is more nested than the deleteLater call). The same thing applies to local event loops started with QEventLoop. The only notable exception I&#8217;ve found to this rule (as of Qt 4.7.3) is that if deleteLater is called when NO event loop is running, then the first event loop entered will pick up the event and delete the object. This is pretty much reasonable, since Qt does not know about any &#8220;outer&#8221; loop that will eventually perform the deletion, and therefore deletes the object immediately.</p>

	<p>.</p>

	<a name="06e458ba8f7f1c02207c32d3157ac217"></a>	<h1>Qt thread classes</h1>

	<blockquote>
		<p>A computer is a state machine. Threads are for people who can&#8217;t program state machines. <br />
&#8212; Alan Cox</p>
	</blockquote>

	<p>Qt has had thread support for many years (Qt 2.2, released on 22 Sept 2000, introduced the QThread class.), and with the 4.0 release thread support is enabled by default on all supported platforms (although it can be turned off, see <a href="http://doc.qt.nokia.com/latest/fine-tuning-features.html">here</a> <em>[doc.qt.nokia.com]</em> for more details). Qt now offers several classes for dealing with threads; let&#8217;s start with an overview.</p>

	<a name="be502ae00ff1867ebe29398c0c9ec833"></a>	<h2>QThread</h2>

	<p><a href="http://doc.qt.nokia.com/latest/qthread.html">QThread</a> <em>[doc.qt.nokia.com]</em> is the central, low-level class for thread support in Qt. A QThread object represents one thread of execution. Due to the cross-platform nature of Qt, QThread manages to hide all the platform-specific code that is needed to use threads on different operating systems.</p>

	<p>In order to use a QThread to run some code in a thread, we can subclass it and override the QThread::run() method:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* your thread implementation goes here */</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>Then we can use</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">Thread <span class="sy0">*</span>t <span class="sy0">=</span> <span class="kw1">new</span> Thread<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">t<span class="sy0">-&gt;</span><span class="me3">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// start(), not run()!</span></div></li>
</ol></div></p>

	<p>to actually start the new thread. Note that since Qt 4.4 QThread is no longer an abstract class; now the virtual method QThread::run() instead simply calls QThread::exec&#40;&#41;;, which starts the <em>thread&#8217;s event loop</em> (more info on this later).</p>

	<a name="8493c32c6b5b4020e2d007b5ee4fcd09"></a>	<h2>QRunnable and QThreadPool</h2>

	<p><a href="http://doc.qt.nokia.com/latest/qrunnable.html">QRunnable</a> <em>[doc.qt.nokia.com]</em> is a lightweight abstract class that can be used to start a task in another thread in a &#8220;run and forget&#8221; fashion. In order to do so, all we have to do is subclass QRunnable and implement its run() pure virtual method:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Task <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QRunnable.html"><span class="kw5">QRunnable</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* your runnable implementation goes here */</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>To actually run a QRunnable object we use the <a href="http://doc.qt.nokia.com/latest/qthreadpool.html">QThreadPool</a> <em>[doc.qt.nokia.com]</em> class, which manages a pool of threads. By calling QThreadPool::start(runnable) we put a QRunnable in a QThreadPool&#8217;s runqueue; as soon as a thread becomes available, the QRunnable will be picked up and run into that thread. All Qt applications have a global thread pool available by calling QThreadPool::globalInstance(), but one can always create a private QThreadPool instance and manage it explicitely.</p>

	<p>Notice that, not being a QObject, QRunnable has no built-in means of explicitely communicating something to other components; you have to code that by hand, using low-level threading primitives (like a mutex-guarded queue for collecting results, etc.).</p>

	<a name="06a6e24fbdb7c79190b6572a617ae5f6"></a>	<h2>QtConcurrent</h2>

	<p><a href="http://doc.qt.nokia.com/latest/threads-qtconcurrent.html">QtConcurrent</a> <em>[doc.qt.nokia.com]</em> is a higher-level <span class="caps">API</span>, built on top of QThreadPool, useful to deal with the most common parallel computation patterns: <a href="http://en.wikipedia.org/wiki/Map_(higher-order_function">map</a> <em>[en.wikipedia.org]</em>), <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function">reduce</a> <em>[en.wikipedia.org]</em>), and <a href="http://en.wikipedia.org/wiki/Filter_(higher-order_function">filter</a> <em>[en.wikipedia.org]</em>) ; it also offers a QtConcurrent::run() method that can be used to easily run a function in another thread.</p>

	<p>Unlike QThread and QRunnable, QtConcurrent does not require us to use low-level synchronization primitives: all QtConcurrent methods instead return a <a href="http://doc.qt.nokia.com/latest/qfuture.html">QFuture</a> <em>[doc.qt.nokia.com]</em> object, which can be used to query the computation status (its progress), to pause/resume/cancel the computation, and that also contains its <em>results</em>. The <a href="http://doc.qt.nokia.com/latest/qfuturewatcher.html">QFutureWatcher</a> <em>[doc.qt.nokia.com]</em> class can be used to monitor a QFuture progress and interact with it by means of signals and slots (notice that QFuture, being a value-based class, doesn&#8217;t inherit QObject).</p>

	<a name="0161e3d40bdbea6ca6998c8c60165b33"></a>	<h2>Feature comparison</h2>

<table class="infotable line"><tr><th>\</th><th>QThread</th><th>QRunnable</th><th>QtConcurrent<sup id="fnrev3044939294f45eee4c3508" class="footnote"><a href="#fn3044939294f45eee4c3508">1</a></sup></th></tr><tr><td>High level <span class="caps">API</span></td><td>✘</td><td>✘</td><td>✔</td></tr><tr><td>Job-oriented</td><td>✘</td><td>✔</td><td>✔</td></tr><tr><td>Builtin support for pause/resume/cancel</td><td>✘</td><td>✘</td><td>✔</td></tr><tr><td>Can run at a different priority</td><td>✔</td><td>✘</td><td>✘</td></tr><tr><td>Can run an event loop</td><td>✔</td><td>✘</td><td>✘</td></tr></table>

	<p id="fn3044939294f45eee4c3508" class="footnote"><sup>1</sup> Except QtConcurrent::run, which is implemented using QRunnable and therefore shares its pros and cons.</p>

	<a name="64a093776750c691afdeb133a80f55e2"></a>	<h1>Threads and QObjects</h1>

	<a name="80c8e93605b398d5fd0833250323bc89"></a>	<h2>Per-thread event loop</h2>

	<p>So far we&#8217;ve always talked about &#8220;<em>the</em> event loop&#8221;, taking somehow per granted that there&#8217;s only one event loop in a Qt application. This is not the case: QThread objects can start thread-local event loops running in the threads they represent. Therefore, we say that the <strong>main event loop</strong> is the one created by the thread which invoked main(), and started with QCoreApplication::exec&#40;&#41; (which <em>must</em> be called from that thread). This is also called the <strong><span class="caps">GUI</span> thread</strong>, because it&#8217;s the only thread in which <span class="caps">GUI</span>-related operations are allowed. A QThread local event loop can be started instead by calling QThread::exec&#40;&#41; (inside its run() method):</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... initialize ... */</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; exec<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>As we mentioned before, since Qt 4.4 QThread::run() is no longer a pure virtual method; instead, it calls QThread::exec&#40;&#41;. Exactly like QCoreApplication, QThread has also the QThread::quit() and QThread::exit() methods to stop the event loop. </p>

	<p>A thread event loop delivers events for all QObjects that are <strong>living</strong> in that thread; this includes, by default, all objects that are created into that thread, or that were moved to that thread (more info about this later). We also say that the <strong>thread affinity</strong> of a QObject is a certain thread, meaning that the object is living in that thread. This applies to objects which are built in the constructor of a QThread object:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> MyThread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; MyThread<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; otherObj <span class="sy0">=</span> <span class="kw1">new</span> QObject<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span> &nbsp; &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> obj<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span>otherObj<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; QScopedPointer<span class="sy0">&lt;</span><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">&gt;</span> yetAnotherObj<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>What&#8217;s the thread affinity of obj, otherObj, yetAnotherObj after we create a MyThread object? We must look at the thread that created them: it&#8217;s the thread that ran the MyThread constructor. Therefore, all three objects are <strong>not</strong> living in the MyThread thread, but in the thread that created the MyThread instance (which, by the way, is where the instance is living as well).</p>

	<p>We can query anytime the thread affinity of a QObject by calling QObject::thread(). Notice that QObjects created before a QCoreApplication object have <strong>no thread affinity</strong>, and therefore no event dispatching will be done for them (in other words, QCoreApplication builds up the QThread object that represents the main thread).</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://doc.qt.nokia.com/4.7/images/threadsandobjects.png" alt="" /></p>

	<p>We can use the thread-safe QCoreApplication::postEvent() method for posting an event for a certain object. This will enqueue the event in the event loop of the thread the object is living in; therefore, the event will not be dispatched unless that thread has a running event loop.</p>

	<p>It is very important to understand that QObject and all of its subclasses <strong>are not thread-safe</strong> (although they can be reentrant); therefore, you can not access a QObject from more than one thread at the same time, unless you serialize all accesses to the object&#8217;s internal data (for instance, by protecting it with a mutex). Remember that the object may be handling events dispatched by the event loop of the thread it is living in while you&#8217;re accessing it from another thread! For the same reason, you can&#8217;t delete a QObject from another thread, but you must use QObject::deleteLater(), which will post an event that will ultimately cause its deletion by the thread the object is living in.</p>

	<p>Moreover, QWidget and all of its subclasses, along with other <span class="caps">GUI</span>-related classes (even not QObject-based, like QPixmap) <strong>are not reentrant</strong> either: they can be used exclusively from the <span class="caps">GUI</span> thread.</p>

	<p>We can change a QObject&#8217;s affinity by calling QObject::moveToThread(); this will change the affinity of the object and of its children. Since QObject is not thread-safe, we must use it from the thread the object is living in; that is, you can only <strong>push</strong> objects from the thread they&#8217;re living in to other threads, and not <strong>pull</strong> them or move them around from other threads. Moreover, Qt requires that the child of a QObject must live in the same thread where the parent is living. This implies that:
	<ul>
		<li>you can&#8217;t use QObject::moveToThread() on a object which has a parent;</li>
		<li>you must not create objects in a QThread using the QThread object itself as their parent:</li>
	</ul></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> obj <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// WRONG!!!</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>This is because the <strong>QThread object is living in another thread</strong>, namely, the one in which it was created.</p>

	<p>Qt also requires that all objects living in a thread are deleted before the QThread object that represents the thread is destroyed; this can be easily done by creating all the objects living in that thread on the QThread::run() method&#8217;s stack.</p>

	<a name="913fb94dd61f1a62fc809f8d842c3afa"></a>	<h2>Signals and slots across threads</h2>

	<p>Given these premises, how do we call methods on QObjects living in other threads? Qt offers a very nice and clean solution: we post an event in that thread&#8217;s event queue, and the handling of that event will consist in invoking the method we&#8217;re interested in (this of course requires that the thread has a running event loop). This facility is built around the method introspection provided by moc: therefore, only signals, slots and methods marked with the Q_INVOKABLE macro are invokable from other threads.</p>

	<p>The QMetaObject::invokeMethod() static method does all the work for us:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QMetaObject.html"><span class="kw5">QMetaObject</span></a><span class="sy0">::</span><span class="me2">invokeMethod</span><span class="br0">&#40;</span>object<span class="sy0">,</span> <span class="st0">&quot;methodName&quot;</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">QueuedConnection</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Q_ARG<span class="br0">&#40;</span>type1<span class="sy0">,</span> arg1<span class="br0">&#41;</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Q_ARG<span class="br0">&#40;</span>type2<span class="sy0">,</span> arg2<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>Notice that since the arguments need to be copied in the event which is built behind the scenes, their types need to provide a public constructor, a public destructor and a public copy constructor, and must be registered within Qt type system by using the qRegisterMetaType() function.</p>

	<p>Signals and slots across threads work in a similar way. When we connect a signal to a slot, the fifth argument of QObject::connect is used to specify the connection type:</p>

	<ul>
		<li>a <strong>direct connection</strong> means that the slot is always invoked directly by the thread the signal is emitted from;</li>
		<li>a <strong>queued connection</strong> means that an event is posted in the event queue of the thread the receiver is living in, which will be picked up by the event loop and will cause the slot invocation sometime later;</li>
		<li>a <strong>blocking queued connection</strong> is like a queued connection, but the sender thread blocks until the event is picked up by the event loop of the thread the receiver is living in, the slot is invoked, and it returns;</li>
		<li>an <strong>automatic connection</strong> (<em>the default</em>) means that if the thread the receiver is living in is the same as the current thread, a direct connection is used; otherwise, a queued connection is used.</li>
	</ul>

	<p>In every case, keep in mind <em>the thread the emitting object is living in</em> has no importance at all! In case of an automatic connection, Qt looks at the thread that invoked the signal and compares it with the thread the receiver is living in to determine which connection type it has to use. In particular, the <a href="http://doc.qt.nokia.com/4.7/threads-qobject.html">current Qt documentation</a> <em>[doc.qt.nokia.com]</em> (4.7.1) <strong>is simply wrong</strong> when it states:</p>

	<p><em>Auto Connection (default) The behavior is the same as the Direct Connection, if the emitter and receiver are in the same thread. The behavior is the same as the Queued Connection, if the emitter and receiver are in different threads.</em></p>

	<p>because the emitter object&#8217;s thread affinity does not matter. For instance:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">signals</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> aSignal<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; emit aSignal<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* ... */</span></div></li>
<li class="li2"><div class="de2">Thread thread<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">Object obj<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="kw2">connect</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>thread<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>aSignal<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="sy0">&amp;</span>obj<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>aSlot<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">thread.<span class="me1">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>The signal aSignal() will be emitted by the new thread (represented by the Thread object); since it is not the thread the Object object is living in (which, by the way, <strong>is the same thread the Thread object is living in</strong>, just to stress that the sender&#8217;s thread affinity doesn&#8217;t matter), a <strong>queued connection</strong> will be used.</p>

	<p>Another common pitfall is the following one:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> aSlot<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">Thread thread<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">Object obj<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="kw2">connect</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>obj<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>aSignal<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="sy0">&amp;</span>thread<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>aSlot<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">thread.<span class="me1">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">obj.<span class="me1">emitSignal</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>When &#8220;obj&#8221; emits its aSignal() signal, which kind of connection will be used? You should&#8217;ve guessed it: a <strong>direct connection</strong>. That&#8217;s because the Thread object is living in the thread that emits the signal. In the aSlot() slot we could then access some Thread&#8217;s member variable while they&#8217;re being accessed by the run() method, which is running concurrently: this is the perfect recipe for disaster. </p>

	<p>Yet another example, probably the <em>most important</em> one:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> aSlot<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span>obj <span class="sy0">=</span> <span class="kw1">new</span> Object<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">connect</span><span class="br0">&#40;</span>obj<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>aSignal<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> SLOT<span class="br0">&#40;</span>aSlot<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>In this case a <strong>queued connection</strong> is used, therefore you&#8217;re required to run an event loop in the thread the Thread object is living in.</p>

	<p>A solution you&#8217;ll often found in forums, blog posts etc. is to add a moveToThread(this) to the Thread constructor:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Thread<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; moveToThread<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// WRONG</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>which indeed <em>will work</em> (because now the affinity of the Thread object changed), but it&#8217;s a very bad design. What&#8217;s wrong here is that we&#8217;re misunderstanding the purpose of a thread object (the QThread subclass): <em>QThread objects are not threads</em>; they&#8217;re control objects around a thread, therefore meant to be used from another thread (usually, the one they&#8217;re living in). </p>

	<p><strong>A good way to achieve the same result</strong> is splitting the &#8220;working&#8221; part from the &#8220;controller&#8221; part, that is, writing a QObject subclass and using QObject::moveToThread() to change its affinity:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Worker <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">public</span> <span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> doWork<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="sy0">*</span>thread <span class="sy0">=</span> <span class="kw1">new</span> QThread<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">Worker <span class="sy0">*</span>worker <span class="sy0">=</span> <span class="kw1">new</span> Worker<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">connect</span><span class="br0">&#40;</span>obj<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>workReady<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> worker<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>doWork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">worker<span class="sy0">-&gt;</span><span class="me3">moveToThread</span><span class="br0">&#40;</span>thread<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">thread<span class="sy0">-&gt;</span><span class="me3">start</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<a name="c61304cd8162519084c4baa3f01ef866"></a>	<h2>DOs and <span class="caps">DON</span>&#8217;Ts</h2>

	<a name="ef8c3ec83a38657dcd15b9735798ad77"></a>	<h3>You can&#8230;</h3>

	<ul>
		<li>&#8230; add signals to a QThread subclass. It&#8217;s perfectly safe and they&#8217;ll do the &#8220;right thing&#8221; (see above; the sender&#8217;s thread affinity does not matter).</li>
	</ul>

	<a name="841270b493224d544ba9f0fe8485c97c"></a>	<h3>You shouldn&#8217;t &#8230;</h3>

	<ul>
		<li>&#8230; use moveToThread(this).</li>
		<li>&#8230; force the connection type: this usually means that you&#8217;re doing something wrong, like mixing the control interface of QThread with the program logic (which should stay in a separate object which lives in that thread).</li>
		<li>&#8230; add slots to a QThread subclass: they&#8217;ll be invoked from the &#8220;wrong&#8221; thread, that is, not the one the QThread object is managing, but the one that object is living in, forcing you to specify a direct connection and/or to use moveToThread(this).</li>
		<li>&#8230; use QThread::terminate.</li>
	</ul>

	<a name="1d82173e75dfb97a97e7e6acb3194ed0"></a>	<h3>You must not&#8230;</h3>

	<ul>
		<li>&#8230; quit your program when threads are still running. Use QThread::wait to wait for their termination.</li>
		<li>&#8230; destroy a QThread while the thread that it&#8217;s managing is still running. If you want some kind of &#8220;self-destruction&#8221;, you can connect the finished() signal with the deleteLater() slot.</li>
	</ul>

	<a name="860bcdee4372c82ce0821a40857eb766"></a>	<h1>When should I use threads?</h1>

	<a name="922f8c2226485920d309b1de41bc8eb1"></a>	<h2>When you have to use a blocking <span class="caps">API</span></h2>

	<p>If you need to use a library or other code that doesn&#8217;t offer a non-blocking <span class="caps">API</span> (by means of signals and slots, or events, or callbacks, etc.), then the only viable solution in order to avoid freezing the event loop is to spawn a process or a thread. Since creating a new worker process, having it doing the job and communicating back the results is definetely harder and more expensive than just starting a thread, the latter is the most common choice.</p>

	<p>A good example of such an <span class="caps">API</span> is <strong>address resolution</strong> (just to show you that we&#8217;re not talking about 3rd-party crappy <span class="caps">API</span>. This is something included in every C library out there), which is the process of taking an host name and converting it into an address. This process involves a query to a (usually remote) system &#8212; the Domain Name System, or <span class="caps">DNS</span>. While, usually, the response is almost instantaneous, the remote servers might fail, some packet might get lost, the network connection might break, and so on; in short, it might take dozens of seconds before we get a reply from our query.</p>

	<p>The only standard <span class="caps">API</span> available on <span class="caps">UNIX</span> systems is <em>blocking</em> (not only the old-fashioned gethostbyname(3), but also the newer and better getservbyname(3) and getaddrinfo(3)). <a href="http://doc.qt.nokia.com/latest/qhostinfo.html">QHostInfo</a> <em>[doc.qt.nokia.com]</em>, the Qt class that handles host name lookups, uses a QThreadPool to enable the queries to run in the background (see <a href="http://qt.gitorious.com/qt/qt/blobs/master/src/network/kernel/qhostinfo.cpp">here</a> <em>[qt.gitorious.com]</em> ; if thread support is turned off, it switches back to a blocking <span class="caps">API</span>).</p>

	<p>Other simple examples are <strong>image loading</strong> and <strong>scaling</strong>. <a href="http://doc.qt.nokia.com/latest/qimagereader.html">QImageReader</a> <em>[doc.qt.nokia.com]</em> and <a href="http://doc.qt.nokia.com/latest/qimage.html">QImage</a> <em>[doc.qt.nokia.com]</em> only offer blocking methods to read an image from a device, or to scale an image to a different resolution. If you&#8217;re dealing with very large images, these processes can take up to (tens of) seconds.</p>

	<a name="fb9db77c23fc9e0a48452ff7250e43fc"></a>	<h2>When you want to scale with the number of <span class="caps">CPU</span>s</h2>

	<p>Threads allow your program to take advantage from multiprocessor systems. Since each thread is scheduled independently by the operating system, if your application is running on such a machine the scheduler is likely to run each thread on a different processor <strong>at the same time</strong>. </p>

	<p>For instance, consider an application that generates thumbnails from a set of images. A <strong>thread farm</strong> of <em>n</em> threads (that is, a thread pool with a fixed number of threads), one per each <span class="caps">CPU</span> available in the system &#40;see also QThread::idealThreadCount() ), can spread the work of scaling down the images into thumbnails on all the threads, effectively gaining an almost linear speedup with the number of the processors (for simplicity&#8217;s sake, we consider the <span class="caps">CPU</span> being the bottleneck).</p>

	<a name="605fc5d1bdd8d9f08192df140937a7c7"></a>	<h2>When you don&#8217;t want to be possibly blocked by others</h2>

	<p><span class="caps">MEH</span>. <span class="caps">BETTER</span> <span class="caps">START</span> <span class="caps">WITH</span> AN <span class="caps">EXAMPLE</span>.</p>

	<p>This is quite an advanced topic, so feel free to skip it for now. A nice example of this use case comes from QNetworkAccessManager usage inside WebKit. WebKit is a modern browser engine, that is, a set of classes to lay out and display web pages. The Qt widget that uses WebKit is QWebView.</p>

	<p>QNetworkAccessManager is a Qt class that deals with <span class="caps">HTTP</span> requests and responses for all purposes, we can consider it to be the networking engine of a web browser. Its current design does not make use of any worker threads; all networking is handled in the same thread QNetworkAccessManager and its QNetworkReplys are living in.</p>

	<p>While not using threads for networking is a very good idea, it has also a major drawback: if you don&#8217;t read data from the socket as soon as possible, the kernel buffers will fill up, packets will begin to be dropped, and the transfer speed will decrease considerably. </p>

	<p>Socket activity (i.e., availability of some data to read from a socket) is managed by Qt&#8217;s event loop. Blocking the event loop will therefore lead to a loss of transfer performance, because nobody will be notified that there are data to read (and thus nobody will read them).</p>

	<p>But what could block the event loop? The sad answer is: WebKit itself! As soon as some data are received, WebKit uses them to start laying out the web page. Unfortunately, the layout process is quite complicated and expensive, therefore it blocks the event loop for a (short) while, enough to impact on ongoing transfers (broadband connections play their role here, filling up kernel buffers in a small fraction of second). </p>

	<p>To sum it up, what happens is something like this:</p>

	<ul>
		<li>WebKit issues a request;</li>
		<li>some data from the reply begin to arrive;</li>
		<li>WebKit starts to lay out the web page using the incoming data, blocking the event loop;</li>
		<li>without a running event loop, data are received by the OS, but not read from QNetworkAccessManager sockets;</li>
		<li>kernel buffers will fill up, and the transfer will slow down.</li>
	</ul>

	<p>The overall page loading time is therefore worsened by this self-induced transfer slowness.</p>

	<p>Notice that since QNetworkAccessManagers and QNetworkReplys are QObjects, they&#8217;re not thread-safe, therefore you can&#8217;t just move them to another thread and continue using them from your thread, because they may be accessed at the same time by two threads: yours and the one they&#8217;re living in, due to events that will be dispatched to them by the latter thread&#8217;s event loop.</p>

	<p>As of Qt 4.8, QNetworkAccessManager now handles <span class="caps">HTTP</span> requests in a separate thread by default, so the result of unresponsive <span class="caps">GUI</span> and OS buffers filling up too quickly should be cured.</p>

	<a name="c2e33c61ced29e1eb1bee9a1671f202e"></a>	<h1>When shouldn&#8217;t I use threads?</h1>

	<blockquote>
		<p>If you think you need threads then your processes are too fat.<br />
&#8212; Rob Pike</p>
	</blockquote>

	<a name="92dd35cc61ffc41d02defdcef071856d"></a>	<h2>Timers</h2>

	<p>This is perhaps the worst form of thread abuse. If we have to invoke a method repeatedly (for instance, every second), many people end up with something like this:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// VERY WRONG</span></div></li>
<li class="li1"><div class="de1"><span class="kw1">while</span> <span class="br0">&#40;</span>condition<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; doWork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; sleep<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// this is sleep(3) from the C library</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Then they figure out that this is <strong>blocking the event loop</strong>, therefore decide to bring in threads:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// WRONG</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">class</span> Thread <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QThread.html"><span class="kw5">QThread</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">protected</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span>condition<span class="br0">&#41;</span> <span class="br0">&#123;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// notice that &quot;condition&quot; may also need volatiness and mutex protection</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// if we modify it from other threads (!)</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; doWork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// this is QThread::sleep()</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>A much <strong>better and simpler way</strong> of achieving the same result is simply using timers, i.e. a <a href="http://doc.qt.nokia.com/latest/qtimer.html">QTimer</a> <em>[doc.qt.nokia.com]</em> object with a 1s timeout, and make the doWork() method a slot:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Worker <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Worker<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">connect</span><span class="br0">&#40;</span><span class="sy0">&amp;</span>timer<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>timeout<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> SLOT<span class="br0">&#40;</span>doWork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; timer.<span class="me1">start</span><span class="br0">&#40;</span><span class="nu0">1000</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span> <span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> doWork<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QTimer.html"><span class="kw5">QTimer</span></a> timer<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>All we need is a running event loop, then the doWork() method will be invoked each second.</p>

	<a name="2b40afeff6025af55f25a6c7ea5ab3bc"></a>	<h2>Networking / state machines</h2>

	<p>A very common design pattern when dealing with network operations is the following one:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="kw2">connect</span><span class="br0">&#40;</span>host<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">waitForConnected</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">data <span class="sy0">=</span> getData<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">socket<span class="sy0">-&gt;</span><span class="me3">write</span><span class="br0">&#40;</span>data<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">waitForBytesWritten</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">waitForReadyRead</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">read</span><span class="br0">&#40;</span>response<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">reply <span class="sy0">=</span> process<span class="br0">&#40;</span>response<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">write</span><span class="br0">&#40;</span>reply<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">socket<span class="sy0">-&gt;</span><span class="me3">waitForBytesWritten</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="coMULTI">/* ... and so on ... */</span></div></li>
</ol></div></p>

	<p>Needless to say, the various waitFor*() calls block the caller without returning to the event loop, freezing the UI and so on. Notice that the above snippet does not take into account any error handling, otherwise it would have been even more cumbersome. What is very wrong in this design is that we&#8217;re forgetting that <strong>networking is asynchronous by design</strong>, and if we build a synchronous processing around we&#8217;re shooting ourselves in the foot. To solve this problem, many people simple move this code into a different thread.</p>

	<p>Another more abstract example:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">result <span class="sy0">=</span> process_one_thing<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span>result<span class="sy0">-&gt;</span><span class="me3">something</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; process_this<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="kw1">else</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; process_that<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">wait_for_user_input<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">input <span class="sy0">=</span> read_user_input<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">process_user_input<span class="br0">&#40;</span>input<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="coMULTI">/* ... */</span></div></li>
</ol></div></p>

	<p>Which has more or less the same pitfalls of the networking example.</p>

	<p>Let&#8217;s take a step back and consider from an higher point of view what we&#8217;re building here: we want to create a <strong>state machine</strong> that reacts on inputs of some sort and acts consequently. For instance, with the networking example, we might want to build something like this:</p>

	<ul>
		<li>Idle → Connecting (when calling connectToHost());</li>
		<li>Connecting → Connected (when connected() is emitted);</li>
		<li>Connected → LoginDataSent (when we send the login data to the server);</li>
		<li>LoginDataSent → LoggedIn (the server replied with an <span class="caps">ACK</span>)</li>
		<li>LoginDataSent → LoginError (the server replied with a <span class="caps">NACK</span>)</li>
	</ul>

	<p>and so forth.</p>

	<p>Now, there are several ways to build a state machine (and Qt even offers a class for that: <a href="http://doc.qt.nokia.com/4.7/qstatemachine.html">QStateMachine</a> <em>[doc.qt.nokia.com]</em> ), the simplest one being an enum (i.e. an integer) used to remember the current state. We can rewrite the above snippets like this:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Object <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw2">enum</span> State <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; State1<span class="sy0">,</span> State2<span class="sy0">,</span> State3 <span class="coMULTI">/* and so on */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; State state<span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Object<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">:</span> state<span class="br0">&#40;</span>State1<span class="br0">&#41;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">connect</span><span class="br0">&#40;</span>source<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>ready<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw1">this</span><span class="sy0">,</span> SLOT<span class="br0">&#40;</span>doWork<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span> <span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> doWork<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span>state<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> State1<span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state <span class="sy0">=</span> State2<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> State2<span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state <span class="sy0">=</span> State3<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* etc. */</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>What the &#8220;source&#8221; object and its &#8220;ready()&#8221; signal are? Exactly what we want them to be: for instance, in the networking example, we might want to connect the socket&#8217;s QAbstractSocket::connected() and the <span class="caps">QIOD</span>evice::readyRead() signals to our slot. Of course, we can also easily add more slots if that suits better in our case (like a slot to manage error situations, which are notified by the QAbstractSocket::error() signal). This is a true asynchronous, signal-driven design!</p>

	<a name="72c9aabadf52900fbf3d4c1ff2b6008c"></a>	<h2>Jobs splittable in chunks</h2>

	<p>Suppose that we have a long computation which can&#8217;t be easily moved to another thread (or that it can&#8217;t be moved at all, because for instance it <em>must run</em> in the <span class="caps">GUI</span> thread). If <strong>we can split the computation in small chunks</strong>, we can return to the event loop, let it dispatch events, and make it invoke the method that processes the next chunk. This can be easily done if we remember how queued connections are implemented: an event is posted in the event loop of the thread the receiver object is living in; when the event is delivered, the corresponding slot is invoked.</p>

	<p>We can use QMetaObject::invokeMethod() to achieve the same result by specifying Qt::QueuedConnection as the type of the invocation; this just requires the method to be invokable, therefore it must be either a slot or marked with the Q_INVOKABLE macro. If we also want to pass parameters to the method, they need to be registered within the Qt metatype system using qRegisterMetaType(). The following snippet shows this pattern: </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> Worker <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span> <span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw4">void</span> startProcessing<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; processItem<span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw4">void</span> processItem<span class="br0">&#40;</span><span class="kw4">int</span> index<span class="br0">&#41;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* process items[index] ... */</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>index <span class="sy0">&lt;</span> numberOfItems<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.qt.nokia.com/doc/QMetaObject.html"><span class="kw5">QMetaObject</span></a><span class="sy0">::</span><span class="me2">invokeMethod</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;processItem&quot;</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">QueuedConnection</span><span class="sy0">,</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Q_ARG<span class="br0">&#40;</span><span class="kw4">int</span><span class="sy0">,</span> index <span class="sy0">+</span> <span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>Since there are no threads involved, it&#8217;s easy to pause/resume/cancel such a computation and collect the results back.</p>

	<a name="fdc53ed8cc27daf8b62151825562a9a5"></a>	<h1>Some examples</h1>

	<a name="0205eacc79baf77a16ff08e24fbba67a"></a>	<h2>MD5 hash</h2>

	<a name="d95867deadfe690e40f42068d6b59df8"></a>	<h1>References</h1>

	<ul>
		<li>Bradley T. Hughes: <a href="http://labs.qt.nokia.com/2010/06/17/youre-doing-it-wrong/">You’re doing it wrong…</a> <em>[labs.qt.nokia.com]</em>, Qt Labs blogs, 2010-06-17</li>
		<li>Bradley T. Hughes: <a href="http://labs.qt.nokia.com/2006/12/04/threading-without-the-headache/">Threading without the headache</a> <em>[labs.qt.nokia.com]</em>, Qt Labs blogs, 2006-12-04</li>
	</ul>]]></description>
      <dc:subject>Threads_Events_QObjects</dc:subject>
      <dc:date>2012-02-21T08:46:35+00:00</dc:date>
    </item>

    <item>
      <title>QtTimers_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/QtTimers_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/QtTimers_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/QtTimers">English</a> <a href="http://developer.qt.nokia.com/wiki/QtTimers-SimplifiedChinese">简体中文</a><br />
<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#a4331ea1aabc508f247455f2ccec4d9f">API-та за таймери</a><ul>
<li><a href="#5ce3fbcdedbf4b2c664ea55d2f5c22c3">QAbstractEventDispatcher</a></li>
<li><a href="#247be240ebad0fca40f2ed1bf9aba3c7">Алгоритъм за заделяне на идентификатори за таймери</a></li>
<li><a href="#603657de228fa405dd8eb484fe3bb9d1">Unix (без glib)</a></li>
<li><a href="#d1849d8671605fdba54ee61b2d1c2a75">Unix (с glib)</a></li>
<li><a href="#aea23489ce3aa9b6406ebb28e0cda430">Windows</a></li>
<li><a href="#41e63e6df83d4c578b90da041e90e011">Реализация на API-то</a></li>
<li><a href="#bf45a4a0f27c0289a60984942530889e">QBasicTimer</a></li>
<li><a href="#ccbef943baa1de42af6d942f811cf841">Още материали</a></li></ul>
</li></ul>
</div></p>

	<p>Написано от: Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="a4331ea1aabc508f247455f2ccec4d9f"></a>	<h1><span class="caps">API</span>-та за таймери</h1>

	<p>Qt предоставя две <span class="caps">API</span>-та за работа с таймери. 
	<ul>
		<li><a href="http://doc.qt.nokia.com/4.7/qobject.html#startTimer">QObject::startTimer</a> <em>[doc.qt.nokia.com]</em> &#8211; Създава повтарящ се таймер за употреба от всеки подклас на QObject и връща идентификатор на таймера. Когато таймера изтече, обекта получава QEvent::Timer, който може да се обработи като се предефинира функцията QObject::timerEvent(QTimerEvent *). Аргумента на QTimerEvent съдържа идентификатора на таймера, с цел да може да се проверява кой таймер е свършил, ако QObject използва няколко. QObject::killTimer(id) може да се използва за спиране на таймера.</li>
	</ul></p>

	<ul>
		<li><a href="http://doc.qt.nokia.com/latest/qtimer.html">QTimer</a> <em>[doc.qt.nokia.com]</em> &#8211; QTimer е QObject, който излъчва сигнала elapsed(), когато таймера изтече. Той просто използва QObject::startTimer() и при обработката на QObject::timerEvent(), излъчва сигнала elapsed().</li>
	</ul>

	<a name="5ce3fbcdedbf4b2c664ea55d2f5c22c3"></a>	<h2>QAbstractEventDispatcher</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/QtEventProcessing">QtEventProcessing</a> <em>[developer.qt.nokia.com]</em> предоставя обобщен преглед на това как Qt обработва събитията от операционната система.</p>

	<p><a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html">QAbstractEventDispatcher</a> <em>[doc.qt.nokia.com]</em> е интерфейсът за изпомпване на събития/съобщения. За всяка нишка, създадена от Qt, съществува по един диспечер на събитията. Той изисква функциите <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#registerTimer-2">registerTimer</a> <em>[doc.qt.nokia.com]</em> и <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#unregisterTimer">unregisterTimer</a> <em>[doc.qt.nokia.com]</em> да бъдат имплементирани, за да може да поддържа таймери. </p>

	<p>Има два варианта на registerTimer (един виртуален и не виртуален). И двата приемат за аргумент QObject-а, който ще използва таймера. Не виртуалният registerTimer (cross-platform) заделя уникален идентификатор и извиква виртуалния registerTimer за реалното регистриране/създаване по специфичен за платформата(ОС) начин. С този подход, платформения диспечер на събитията поддържа списък с таймерите, асоциирани с даден QObject. <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#registeredTimers">QAbstractEventDispatcher::registeredTimers</a> <em>[doc.qt.nokia.com]</em> може да се използва за взимане на лист с таймерите, свързани с QObject.</p>

	<p>На ниско ниво, след като веднъж е създаден таймер,  неговият интервал не може да се сменя и поради трябва да се счита за неизменяем. <span class="caps">API</span>-то от високо ниво трябва да създаде нов таймер, за да промени интервала. Също така, таймерите продължават да работят, докато не бъдат убити и няма концепция за единични таймери в интерфейса на диспечера на събитията. <span class="caps">API</span>-тата от високо ниво трябва да симулират единични таймери като спират регистрацията си за таймер след като мине първия интервал.</p>

	<a name="247be240ebad0fca40f2ed1bf9aba3c7"></a>	<h2>Алгоритъм за заделяне на идентификатори за таймери</h2>

	<p>Алгоритъма за заделяне на идентификатори за таймери е свободен и може да се разгледа в <a href="http://labs.trolltech.com/blogs/2008/10/22/a-never-ending-struggle/">блога на Брад</a> <em>[labs.trolltech.com]</em>.</p>

	<p>Важно е да се отбележи, че идентификаторите на таймерите трябва да са уникални, даже и при употреба в различни нишки. Това е така, защото когато <a href="http://developer.qt.nokia.com/doc/qt-4.8/qobject.html">QObject</a> <em>[developer.qt.nokia.com]</em> бъде преместен от нишка в друга нишка, таймерите му се преместват също (т.е сигналите и събитията вече се доставят през цикъла на събитията в новата нишка). Преместването на таймер е просто &#8211; премахва се регистрацията му от диспечера в старата нишка и се регистрира в този на новата. Ако идентификаторите на таймерите не бяха уникални, можеха да се препокрият със вече съществуващи в новата нишка. Ако нови идентификатори се генерираха при QObject::moveToThread, то приложението трябваше да бъде уведомено за промяната, а това е неудобно за разработчиците на приложения.</p>

	<a name="603657de228fa405dd8eb484fe3bb9d1"></a>	<h2>Unix (без glib)</h2>

	<p>В Unix, QEventDispatcherUNIX имплементира диспечера на събитията. Той поддържа списък с таймери, сортирани по времето им на изтичане. Когато се регистрира таймер, неговото време на изтичане се пресмята като се добави периода към монотонния часовник (clock_gettime). На системи, които не поддържат такъв часовник, се използва gettimeofday.</p>

	<p>Диспечера разчита на select(), за да чака за събития от всички файлови дескриптори (връзки от X, сокети). При влизане в processEvents(), диспечера първо обновява периода на изтичане на всички регистрирани таймери. После предоставя времето на изтичане на системното извикване select() като интервал в първият таймер в листа. След завръщането си от <em>select</em>, диспечера &#8220;активира&#8221; изтеклите таймери като изпраща на съответните QObject-и QEvent::Timer.</p>

	<p>Забележете, че Qt не използва <span class="caps">POSIX</span> <span class="caps">API</span>-то за таймери &#8211; timerfd_create (Защо? Преносимост?).</p>

	<a name="d1849d8671605fdba54ee61b2d1c2a75"></a>	<h2>Unix (с glib)</h2>

	<p>Qt може да се компилира така, че да използва цикъла на събитията на glib (по подразбиране), което помага за по-добрата интеграция с Gtk. <a href="http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-7FD05006-09C1-4EF4-A2EB-AD98C2FA8866.html">Документация на цикъла в Glib</a> <em>[developer.symbian.org]</em>&#8221; предоставя допълнителна информация за това как той е реализиран.</p>

	<p>Точно като QEventDispatcherUNIX, QEventDispatcherGlib управлява таймерите като сортиран по време на изтичане лист. Той създава нов GSource за таймери. Функциите за подготовка, проверката и изпращане на този GSource работят по очевидния начин.</p>

	<a name="aea23489ce3aa9b6406ebb28e0cda430"></a>	<h2>Windows</h2>

	<p>Както е отбелязано в <a href="http://developer.qt.nokia.com/wiki/QtEventProcessing">QtEventProcessing</a> <em>[developer.qt.nokia.com]</em>, Qt създава скрит прозорец с указател към функция(callback), за да обработва събития. Когато се регистрира таймер, QEventDispatcherWin създава вграден Windows таймер, базирайки се на интервала. </p>

	<ul>
		<li>Ако интервалът е по-голям от 20 милисекунди, се използва SetTimer (с идентификатор, създаден чрез QAbstractEventDispatcher::registerTimer). SetTimer изпраща съобщение WM_TIMER към подадената функция, което се препраща като QEvent::Timer към QObject.</li>
	</ul>

	<ul>
		<li>Ако интервалът е по-малък от 20 милисекунди, Qt се опитва да използва мултимедийните (известни също като &#8220;бързи&#8221;) таймери чрез timeSetEvent. timeSetEvent приема указател към функция, която се извиква при изтичане и това става в отделна нишка. В Qt обаче, таймерите работят в същата нишка, в която е и QObject. За това функцията, подадена на timeSetEventlback, пуска съобщение към диспечера, което той прихваща и предава като QEvent::Timer.</li>
	</ul>

	<ul>
		<li>Ако интервалът е 0, диспечера създава специално съобщение към себе си (QEvent::ZeroTimerEvent) при регистрация на таймера. После той обработва това събитие като изпраща QEvent::Timer към съответния QObject и ZeroTimerEvent към себе си.</li>
	</ul>

	<a name="41e63e6df83d4c578b90da041e90e011"></a>	<h2>Реализация на <span class="caps">API</span>-то</h2>

	<p>QObject::startTimer регистрира нов таймер в диспечера на събитията. Това е приблизително еквивалентно на, QAbstractEventDispatcher::instance(object-&gt;thread())-&gt;registerTimer(интервал, обект).</p>

	<p>QTimer е QObject. Всичко, което прави е да извика QObject::startTimer(). Той излъчва сигнала activated() в своя timerEvent().</p>

	<a name="bf45a4a0f27c0289a60984942530889e"></a>	<h2>QBasicTimer</h2>

	<p>QTimer изглежда тежък, тъй като е QObject и често се избягва в Qt код. В същото време, използването на QObject::startTimer() <span class="caps">API</span>-то предразполага към грешки.
	<ol>
		<li>Когато спирате таймер, трябва да направите идентификатора му невалиден (примерно да го приравните на -1) след QObject::killTimer(m_timerId). Това се изисква, тъй като положителна стойност на m_timerId ще индикира, че таймера е активен.</li>
	</ol></p>

	<ol>
		<li>За да рестартирате таймер, трябва да запомните, че първо трябва да спрете предишния таймер, ако m_timerId е различно от -1.</li>
	</ol>

	<p>QBasicTimer решава горният проблем и е просто подобрен интерфейс около &#8220;идентификатора на таймера&#8221;. QBasicTimer::start(int msec, QObject *) спира всички съществуващи таймери към този обект и създава нов, използвайки object-&gt;startTimer(msec). QBasicTimer::stop() спира таймера и слага идентификатора му на невалидна стойност. QBasicTimer::timerId() предоставя идентификатора.</p>

	<a name="ccbef943baa1de42af6d942f811cf841"></a>	<h2>Още материали</h2>

	<ul>
		<li><a href="http://labs.trolltech.com/blogs/2008/10/22/a-never-ending-struggle/">Безкрайната борба</a> <em>[labs.trolltech.com]</em> &#8211; Алгоритъм за заделяне на идентификатори за таймери</li>
	</ul>]]></description>
      <dc:subject>QtTimers_Bulgarian</dc:subject>
      <dc:date>2012-02-20T22:22:07+00:00</dc:date>
    </item>

    <item>
      <title>QtTimers</title>
      <link>http://developer.qt.nokia.com/wiki/QtTimers</link>
      <guid>http://developer.qt.nokia.com/wiki/QtTimers</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/QtTimers-SimplifiedChinese">简体中文</a> <a href="http://developer.qt.nokia.com/wiki/QtTimers_Bulgarian">Български</a><br />
<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#d716904f477c68392c20692d1619c773">The timer APIs</a><ul>
<li><a href="#5ce3fbcdedbf4b2c664ea55d2f5c22c3">QAbstractEventDispatcher</a></li>
<li><a href="#53ba059c5f542acee67735855d0a5598">Timer id allocation algorithm</a></li>
<li><a href="#6b69c0291389c7fc80f147e3987b9cb3">Unix (without glib)</a></li>
<li><a href="#6051f55407cdae141b6d187f6b2a45ca">Unix (with glib)</a></li>
<li><a href="#aea23489ce3aa9b6406ebb28e0cda430">Windows</a></li>
<li><a href="#2b38e3c1b27a8849e20fac5c2bb865af">API implementation</a></li>
<li><a href="#bf45a4a0f27c0289a60984942530889e">QBasicTimer</a></li>
<li><a href="#1ba5c1747d37a3d7ae84fd1dcac77603">Further reading</a></li></ul>
</li></ul>
</div></p>

	<p>Written By : Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="d716904f477c68392c20692d1619c773"></a>	<h1>The timer <span class="caps">API</span>s</h1>

	<p>Qt provides two <span class="caps">API</span>s to work with timer. 
	<ul>
		<li><a href="http://doc.qt.nokia.com/4.7/qobject.html#startTimer">QObject::startTimer</a> <em>[doc.qt.nokia.com]</em> &#8211; Creates a recurring timer for use by any QObject subclass and returns the timer id. When the timer expires it receives a QEvent::Timer that can be handled by overriding QObject::timerEvent(QTimerEvent *). The QTimerEvent argument contains the timer id which can be matched against if the QObject uses multiple timers. QObject::killTimer(id) can be used to stop and disarm the timer.</li>
	</ul></p>

	<ul>
		<li><a href="http://doc.qt.nokia.com/latest/qtimer.html">QTimer</a> <em>[doc.qt.nokia.com]</em> &#8211; QTimer is a QObject which emits the elapsed() signal when the timer expires. It simply uses QObject::startTimer() and in the QObject::timerEvent() event handler, it emits the elapsed() signal.</li>
	</ul>

	<a name="5ce3fbcdedbf4b2c664ea55d2f5c22c3"></a>	<h2>QAbstractEventDispatcher</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/QtEventProcessing">QtEventProcessing</a> <em>[developer.qt.nokia.com]</em> provides an overview of how platform events are processed by Qt.</p>

	<p><a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html">QAbstractEventDispatcher</a> <em>[doc.qt.nokia.com]</em> is the interface for the event/message pump. An event dispatcher exists for each thread created using Qt. It requires <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#registerTimer-2">registerTimer</a> <em>[doc.qt.nokia.com]</em> and <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#unregisterTimer">unregisterTimer</a> <em>[doc.qt.nokia.com]</em> to be implemented for timers. </p>

	<p>There are two versions of the registerTimer (one virtual and one non-virtual). Both versions take an argument to QObject that the timer is to be associated with. The non-virtual registerTimer (cross-platform) allocates a unique timer id and calls the virtual registerTimer for actually registering/creating the timer in a platform-specific way. With this approach, the platform event dispatcher maintains the list of timers associated with a QObject. <a href="http://doc.qt.nokia.com/latest/qabstracteventdispatcher.html#registeredTimers">QAbstractEventDispatcher::registeredTimers</a> <em>[doc.qt.nokia.com]</em> can be used to query the list of timers associated with a QObject.</p>

	<p>At the low level, once you register a timer, its interval cannot be changed and should be considered as immutable. A high-level <span class="caps">API</span> has to create a new timer to change the interval. Also, timers keep firing (i.e recurring) until killed and there is no concept of a &#8220;single shot&#8221; in the event dispatcher interface. High level <span class="caps">API</span>s have to emulate a single shot timer by unregistering the timer after the first interval expires.</p>

	<a name="53ba059c5f542acee67735855d0a5598"></a>	<h2>Timer id allocation algorithm</h2>

	<p>The algorithm for timer id allocation is lock-free and can be studied from <a href="http://labs.trolltech.com/blogs/2008/10/22/a-never-ending-struggle/">Brad&#8217;s blog</a> <em>[labs.trolltech.com]</em>.</p>

	<p>An important fact is that timer ids are required to be unique even across threads. This is because when a QObject moves from one thread to another, its timers also move along with it (i.e signals and events are now delivered through the new thread&#8217;s event loop). Moving the timer is simply a matter of unregistering the timer from the old thread&#8217;s dispatcher and registering in the new thread&#8217;s dispatcher. If the timer ids were not unique, the timer ids might clash with existing timers in the new thread. If fresh timer ids were to be regenerated on a QObject::moveToThread, then the application needs to be notified about the id changes and this is a hassle for the application programmer.</p>

	<a name="6b69c0291389c7fc80f147e3987b9cb3"></a>	<h2>Unix (without glib)</h2>

	<p>On Unix, QEventDispatcherUNIX implements the event dispatcher. It maintains a list of timers sorted by their expiry time. When a timer is registered, it&#8217;s expiry time is computed by adding the timeout value to monotonic clock (clock_gettime). On systems that do not support monotonic clock, gettimeofday is used. The timer is then inserted into a list sorted based on its expiry interval (first item expires first).</p>

	<p>The dispatcher relies on select() to wait for events on all fds (the X connection, sockets). It first updates the expiry interval for all the registered timers when processEvents() is entered. It then provides the timeout to the select() system call as the interval in the first item of the timer list. After returning from select, the dispatcher &#8220;activates&#8221; expired timers by sending the associated QObjects a QEvent::Timer.</p>

	<p>Note that Qt does not use the <span class="caps">POSIX</span> timer <span class="caps">API</span> &#8211; timerfd_create (Why? Portability?).</p>

	<a name="6051f55407cdae141b6d187f6b2a45ca"></a>	<h2>Unix (with glib)</h2>

	<p>Qt can be compiled to use the glib event loop (the default) which helps it integrate better with Gtk. <a href="http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-7FD05006-09C1-4EF4-A2EB-AD98C2FA8866.html">Glib loop documentation</a> <em>[developer.symbian.org]</em>&#8221; provides an introduction to how glib loops are written.</p>

	<p>Just like QEventDispatcherUNIX, QEventDispatcherGlib manages timers in a list sorted on expiry time. It creates a new GSource for timers. The prepare, check and dispatch functions of this custom GSource work on the timer list in the obvious way.</p>

	<a name="aea23489ce3aa9b6406ebb28e0cda430"></a>	<h2>Windows</h2>

	<p>As noted in <a href="http://developer.qt.nokia.com/wiki/QtEventProcessing">QtEventProcessing</a> <em>[developer.qt.nokia.com]</em>, Qt creates a hidden window with a callback function to process events. When a timer is registered, QEventDispatcherWin creates a native Windows timer based on the timer interval. </p>

	<ul>
		<li>If the interval is greater than 20 msecs, it uses SetTimer (with the id that was generated by QAbstractEventDispatcher::registerTimer). SetTimer sends a WM_TIMER message to the callback function that gets sent as QEvent::Timer to the QObject.</li>
	</ul>

	<ul>
		<li>If the interval is less than 20 msecs, Qt tries to use multimedia (aka fast) timers using timeSetEvent. timeSetEvent takes a callback function that is called on expiry and will be called from a separate thread. In Qt, timers fire in the same thread as that of the QObject. So the timeSetEvent&#8217;s callback function posts a message to the dispatcher which the dispatcher picks up and sends as QEvent::Timer.</li>
	</ul>

	<ul>
		<li>If the interval is 0, the dispatcher posts a special message to itself (QEvent::ZeroTimerEvent) on registration. The dispatcher processes this event by sending a QEvent::Timer to the corresponding QObject and posts a ZeroTimerEvent to itself.</li>
	</ul>

	<a name="2b38e3c1b27a8849e20fac5c2bb865af"></a>	<h2><span class="caps">API</span> implementation</h2>

	<p>QObject::startTimer registers a new timer with event dispatcher. This is roughly the equivalent of, QAbstractEventDispatcher::instance(object-&gt;thread())-&gt;registerTimer(interval, object).</p>

	<p>QTimer is a QObject. All it does is call QObject::startTimer(). It emits activated() signal in it&#8217;s timerEvent().</p>

	<a name="bf45a4a0f27c0289a60984942530889e"></a>	<h2>QBasicTimer</h2>

	<p>QTimer feels heavy since it&#8217;s a QObject and in general Qt code tries to avoid it. At the same time, using the QObject::startTimer() <span class="caps">API</span> is a bit error-prone.
	<ol>
		<li>When stopping a timer, you have to invalidate the timer id (say to -1) after QObject::killTimer(m_timerId). This is required since a positive value for m_timerId will indicate to your code that the timer is active.</li>
	</ol></p>

	<ol>
		<li>To restart a timer, one needs to remember to kill the old timer if m_timerId is not -1.</li>
	</ol>

	<p>QBasicTimer solves the above and is just a glorified interface to the integer &#8220;timer id&#8221;. QBasicTimer::start(int msec, QObject *) kills any existing timer and create a new one using object-&gt;startTimer(msec). QBasicTimer::stop() will kill the timer and invalidate the id. QBasicTimer::timerId() provides the timer id.</p>

	<a name="1ba5c1747d37a3d7ae84fd1dcac77603"></a>	<h2>Further reading</h2>

	<ul>
		<li><a href="http://labs.trolltech.com/blogs/2008/10/22/a-never-ending-struggle/">A never-ending struggle</a> <em>[labs.trolltech.com]</em> &#8211; Timer id allocation algorithm</li>
	</ul>]]></description>
      <dc:subject>QtTimers</dc:subject>
      <dc:date>2012-02-20T21:29:36+00:00</dc:date>
    </item>

    <item>
      <title>PySide_Python_3_Issues</title>
      <link>http://developer.qt.nokia.com/wiki/PySide_Python_3_Issues</link>
      <guid>http://developer.qt.nokia.com/wiki/PySide_Python_3_Issues</guid>
      <description><![CDATA[<a name="b5f84ea7af88a34db4fc9dc2534b84e2"></a>	<h1>What&#8217;s needed to port Shiboken to Python 3</h1>

	<p><strong>Note:</strong> The Python3 support related ideas were moved to <a href="http://developer.qt.nokia.com/wiki/PySide_Python_3_Support">PySide_Python_3_Support</a>!</p>

	<ul>
		<li>Python 3 C <span class="caps">API</span> <a href="http://docs.python.org/release/3.0.1/howto/cporting.html">doesn&#8217;t have PyInt _ * functions, just PyLong _</a> <em>[docs.python.org]</em>. The code used to handle type conversions recognizes the use of PyInt and PyLong. The proper code for conversion is executed depending on the scenario.
	<ul>
		<li>Possible fix: Create PyInt _ * aliases to PyLong _ * functions.</li>
		<li>Severity: Low</li>
	</ul></li>
		<li>Python 3 module initialization is completely different from Python 2, support both types of initialization would be trick<sup id="fnrev14123501174f45eee60cb63" class="footnote"><a href="#fn14123501174f45eee60cb63">1</a></sup>.
	<ul>
		<li>Possible fix: Change the generator to generate different initialization routines for different Python versions or pollute the generated module initialization routine with #ifdef&#8217;s.</li>
		<li>Severity: Medium</li>
	</ul></li>
		<li><a href="http://www.python.org/dev/peps/pep-0384/">PyTypeObject layout changed in Python 3</a> <em>[python.org]</em> . As many PyType objects are defined in libshiboken this implies in some ugly changes to libshiboken to get the source code supporting both Python versions.
	<ul>
		<li>Possible fix: Do an &#8220;#ifdef festival&#8221; on libshiboken and on code generated by the generator to handle the differences between Python versions.</li>
		<li>Severity: High</li>
	</ul></li>
		<li><a href="http://www.python.org/dev/peps/pep-3149/">Python libraries will be <span class="caps">ABI</span> version tagged from 3.2 on</a> <em>[python.org]</em>
	<ul>
		<li>Possible fix: Support it in CMakeLists.txt.</li>
		<li>Severity: Medium</li>
	</ul></li>
		<li>Can&#8217;t access PyObject attributes from a PyTypeObject without cast it to PyObject beforehand.
	<ul>
		<li>Possible fix: Cast it!</li>
		<li>Severity: Low</li>
	</ul></li>
		<li>Removal of PyString, addition of PyByte.
	<ul>
		<li>Possible fix: Create some aliases to the respective PyUnicode functions or add #ifdefs when the aliasing solution isn&#8217;t possible.</li>
		<li>Severity: Medium</li>
	</ul></li>
		<li>CMake knows nothing about Python 3.
	<ul>
		<li>Possible fix: Write our own findPython3 function to detect Python 3 on the underlying system.</li>
		<li>Severity: Medium</li>
	</ul></li>
	</ul>

	<p>Summarizing, porting shiboken to Python 3 isn&#8217;t going to be a trivial task and support both versions will be even harder but not impossible.</p>]]></description>
      <dc:subject>PySide_Python_3_Issues</dc:subject>
      <dc:date>2012-02-20T19:11:49+00:00</dc:date>
    </item>

    <item>
      <title>Chicken_Wranglers</title>
      <link>http://developer.qt.nokia.com/wiki/Chicken_Wranglers</link>
      <guid>http://developer.qt.nokia.com/wiki/Chicken_Wranglers</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#20f426276699ab8e0b25518facda1e83">Chicken Wranglers - Showcase app</a><ul>
<li><a href="#0b4a1fd2370952e6f7c276106ee02957">Game Development</a><ul>
<li><a href="#1f0c33cad152b478b2d99effeed2dfab">The Mobile as a Remote control</a></li>
<li><a href="#9bd9d0ebc081bd74f5bef4e136bb1aed">Connectivity</a></li>
<li><a href="#0827540eace7411321f251f39d57b98d">UI and Animation</a></li>
<li><a href="#890fcd820a125b25d08e054bfdf016bb">Making Smart Chickens</a></li>
<li><a href="#ce67d6b327df5d9b44f3d13469c97812">Porting and Optimizations</a></li></ul>
</li>
<li><a href="#6f8b794f3246b0c1e1780bb4d4d5dc53">Conclusion</a></li>
<li><a href="#24b6472fcfa59cddd3f7bbc326582b5f">Controls</a></li>
<li><a href="#ee3be02a348c69a135421826231bf263">Binaries </a></li>
<li><a href="#f31bbdd1b3e85bccd652680e16935819">Source</a></li></ul>
</li></ul>
</div>

	<a name="20f426276699ab8e0b25518facda1e83"></a>	<h1>Chicken Wranglers &#8211; Showcase app</h1>

	<p><object width="480" height="385"><param name="movie" value="http://www.youtube-nocookie.com/v/r98k10pLuEg?fs=1&amp;hl=en_US&amp;rel=0&amp;color1=0x234900&amp;color2=0x4e9e00"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/r98k10pLuEg?fs=1&amp;hl=en_US&amp;rel=0&amp;color1=0x234900&amp;color2=0x4e9e00" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>

	<p><em>Listen to the INdT team in Brazil about how they used Qt to make a multiplayer and cross-device game using mobiles devices as the controllers.</em></p>

	<p>The original premise of this project was the development of an application to showcase how Qt and <span class="caps">QML</span> can support interoperability between different platforms and devices.</p>

	<p>The idea started to shape as a cross-device game, where several players could use their mobiles as remote controls and a big screen as a main game board.</p>

	<p>After several proposals being considered, the designers presented a quite charming and funny game concept: farmers trying to capture chickens on their hencoops, using laser walls to trap them.</p>

	<p>The challenge ahead: how to implement this concept with a small team (with zero previous experience in <span class="caps">QML</span> and no gaming development experience as well) in a really tight schedule?</p>

	<p>If successful, this could be the perfect scenario to prove how was the <span class="caps">QML</span> learning curve and how productive it could be.</p>

	<a name="0b4a1fd2370952e6f7c276106ee02957"></a>	<h2>Game Development</h2>

	<p>It was clear that some components would be required for assembling a multiplayer networked game, so the team decided to start implementing modules that could be used independently of how the idea would evolve. The demands at this stage were interoperability and client devices acting as remote controllers.</p>

	<a name="1f0c33cad152b478b2d99effeed2dfab"></a>	<h3>The Mobile as a Remote control</h3>

	<p>The first module to be developed was the game controller. For input the team decided to use the accelerometer sensor for moving the characters. Qt Mobility features a sensors module that provides access to the device accelerometers.</p>

	<p>Character movements were quite simple (up, down, right, left, stop), being just a matter of capturing accelerometer data and converting to discrete directions. The main challenge here was to fine tune those values such that it wouldn&#8217;t be hard for the user to guide his character through the battlefield.</p>

	<p>It required some degree of experimentation to achieve good thresholds for handling common commands. Some parameters were used to aid the calculations:</p>

	<ul>
		<li>The minimum angle the device needs to be rotated to trigger a direction change.</li>
		<li>A threshold between two directions in the same axis (e.g. up and stopped) so the controller does not keep oscillating between them.</li>
		<li>Direction changing timeout, to check if the time spent in a given direction is not too short. This avoids undesired direction changes.</li>
	</ul>

	<a name="9bd9d0ebc081bd74f5bef4e136bb1aed"></a>	<h3>Connectivity</h3>

	<p>Before working on the connectivity itself, it was defined a communication protocol (messages and states to be exchanged between the devices), targeting to support both <span class="caps">WLAN</span> and bluetooth. Qt has great networking support, so it was relatively easy to implement connectivity via local network (therefore <span class="caps">WLAN</span>).</p>

	<p>Qt Mobility 1.2 offers bluetooth classes for device management (discovering, pairing, etc) and message interchanging. It maps closely to the networking classes, enabling the initial <span class="caps">WLAN</span> code to be later translated to be used for bluetooth connections.</p>

	<p>To support both <span class="caps">WLAN</span> and Bluetooth connectivity it a common abstraction was created for representing a network connection (QBluetoothSocket and QTcpSocket don&#8217;t share the same immediate parent class), thus signals diverge in type signature besides being quite similar. This allowed the application to switch the type of connectivity used at run time.</p>

	<a name="0827540eace7411321f251f39d57b98d"></a>	<h3>UI and Animation</h3>

	<p>One major concern was on the visual aspects of the game: how to make rich user interface screens, fancy transitions and animations to look beautiful and run smoothly.</p>

	<p>That is where <span class="caps">QML</span> (Qt Modeling Language) came to the rescue. The team was formed by proficient programmers in C++/Qt/Linux but, as explained earlier, no previous experience with <span class="caps">QML</span>.</p>

	<p>It turned out to be a pleasant surprise how easy and intuitive was to implement animations and effects while building the user interface in a declarative way. The possibilities of integration between C++ and the declarative language were seamless, enabling logic coded in native code to easily plug into Javascript based <span class="caps">QML</span>.</p>

	<p>This way, we could keep the performance sensitive code paths in the native side (e.g. the chickens&#8217; artificial intelligence, collision detection and connectivity, to name a few) and let only the visual implementation on the declarative side.</p>

	<a name="890fcd820a125b25d08e054bfdf016bb"></a>	<h3>Making Smart Chickens</h3>

	<p>To make the chickens look like they are smart, it a module was created to add some intelligence to them. It basically changes the position of the chickens based on the proximity of the farmers or of hencoops. This logic enables the chickens to avoid wranglers and coops whenever possible and features a pseudo random criteria of avoidance, enriching the gaming experience.</p>

	<p>The game elements (wranglers, hencoop, chickens, lasers) are logically represented on a matrix, in order to help the module to detect collisions and calculate the runaway logic.</p>

	<a name="ce67d6b327df5d9b44f3d13469c97812"></a>	<h3>Porting and Optimizations</h3>

	<p>The next step to fulfill the original vision of being truly cross-platform was a port to Symbian. The possibility of a port was only made possible starting with Qt Mobility 1.2 beta being made available (this is required to support bluetooth connectivity).</p>

	<p>The first step was to change the buildsystem to couple with Symbian idiosyncrasies. While the initial buildsystem allowed to build different components as shared libraries (thus helping in debugging), to adapt to Symbian the application buildsystem was changed to build its submodules as a single project.</p>

	<p>The app successfully launched in Symbian, but its memory footprint was above the maximum heapsize, as also the default stack size. These memory problems required some optimizations like using smaller image assets, installable character models (instead of using Qt resources for everything) and lazy loading of some screens.</p>

	<p>Next, the screens got to be made more scalable (the game targeted the resolution of Nokia N900, which is bigger than Symbian devices like Nokia N8). The next step was to dynamically load assets depending on the environment and fine tune parameters animations (i.e. the feathers animation will use different number of feathers depending on the environment). This together with some reordering and refactoring of screen elements brought some benefits for CW in both environments, like faster app startup and better framerates. The end result was a reduction of memory usage from above 80MB to just 15MB of <span class="caps">RAM</span>.</p>

	<p>Finally, much improved frame rates were achieved by simply using a <span class="caps">QGLW</span>idget thus unleashing OpenGL hardware acceleration for free. At end, we even got host mode to run successfully in the mobile (hosting up to 4 players at same time) with pretty good <span class="caps">CPU</span> usage (load around 65%) and framerates.</p>

	<a name="6f8b794f3246b0c1e1780bb4d4d5dc53"></a>	<h2>Conclusion</h2>

	<p>Qt technologies made possible to write from scratch a game for mobile devices in a short schedule with a small team, enabling quick implementation of designer&#8217;s mockups into real code.</p>

	<p>It features support for everything needed to turn ideas into a running application: networking, bluetooth, accelerometer and graphics. The fact that it is possible to use C++ for more complex code paths, brings a huge advantage while coding games.</p>

	<p>Add a declarative way for UI development in the mix and you achieve a winning combination for rapid application development.<br />
How to Play</p>

	<p>Chicken Wranglers is a 2-4 players game, where each player is a farmer whose goal is to capture as much chickens as he can while a timer is running. The chickens walk freely across a bi-dimensional grid, always trying to escape from the farmers and their chicken coops.</p>

	<p>In order to push chickens to his coop, the farmer can activate lasers in the grid to build mazes that should restrain the chickens&#8217; path and guide them to the coop. The lasers can be placed at any edge of a cell (up, down, left or right) where the farmer is currently located. Although active lasers are supposed to help a farmer, the other farmers can deactivate any laser at any time. This enables a farmer to have his maze broken by his opponents.</p>

	<p>Note that neither chickens nor farmers are allowed to cross a laser wall before it is deactivated.<br />
Score</p>

	<p>Each time a chicken cross a farmer&#8217;s coop, the corresponding player scores 1 point. After the timer expires, the player with the highest score wins.</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://developer.qt.nokia.com/uploads/image_upload/CW.png" alt="" /></p>

	<p><em>Ashley Walker holds the Chicken Wrangler title with wrangling all 40 chickens into the hen house before the clock ran out. She was undefeated at the MeeGo Conference this spring. Do you have what it takes to steal the CW title?</em></p>

	<a name="24b6472fcfa59cddd3f7bbc326582b5f"></a>	<h2>Controls</h2>

	<p><strong>Movement</strong> &#8211; A player controls his character direction via device accelerometer. The characters moves in four directions: up, down, left and right according to device tilting on any of those directions. If the device is tilted diagonally (e.g. up and left), the predominant direction will be the most tilted one.</p>

	<p><strong>Lasers</strong> &#8211; Tapping on screen toggles a laser on the corresponding direction of the player character&#8217;s position. For instance, if the player taps on the top of the screen, the laser is activated/deactivated above the character&#8217;s position. </p>

	<a name="ee3be02a348c69a135421826231bf263"></a>	<h2>Binaries </h2>

	<p>Harmattan (N9 / N950): <a href="http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_harmattan_armel.deb">http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_harmattan_armel.deb</a></p>

	<p>Fremantle (N900): <a href="http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_fremantle_armel.deb">http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_fremantle_armel.deb</a></p>

	<p>Ubuntu 11.04: <a href="http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_i386.deb">http://get.qt.nokia.com/demos/chicken-wranglers/chicken-wranglers_0.1-0_i386.deb</a></p>

	<a name="f31bbdd1b3e85bccd652680e16935819"></a>	<h2>Source</h2>

	<p><a href="http://qt.gitorious.org/qt-labs/mobile-demos/trees/master/chicken-wranglers">http://qt.gitorious.org/qt-labs/mobile-demos/trees/master/chicken-wranglers</a></p>]]></description>
      <dc:subject>Chicken_Wranglers</dc:subject>
      <dc:date>2012-02-20T13:01:53+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools &#45;&gt; KD SOAP</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools::KD&#45;SOAP</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools::KD&#45;SOAP</guid>
      <description><![CDATA[<p><a href="http://www.kdab.com/kd-soap">KD <span class="caps">SOAP</span></a> <em>[kdab.com]</em></p>

	<p>KD Soap is a web service access package for Qt applications.</p>

	<p>KD <span class="caps">SOAP</span> is a tool for creating client applications for web services and also provides the means to create web services without the need for any further component such as a dedicated web server. It makes it possible to interact with applications which have <span class="caps">API</span>s that can be exported as <span class="caps">SOAP</span> objects. The web service then provides a machine-accessible interface to its functionality via <span class="caps">HTTP</span>.</p>

	<p>Code generators for the client and the server side make it really easy to write <span class="caps">SOAP</span> clients and servers in Qt.</p>]]></description>
      <dc:subject>Category:Tools &#45;&gt; KD SOAP</dc:subject>
      <dc:date>2012-02-19T13:01:49+00:00</dc:date>
    </item>

    <item>
      <title>How_to_use_gSOAP_with_Qt_for_Web_Service_Client</title>
      <link>http://developer.qt.nokia.com/wiki/How_to_use_gSOAP_with_Qt_for_Web_Service_Client</link>
      <guid>http://developer.qt.nokia.com/wiki/How_to_use_gSOAP_with_Qt_for_Web_Service_Client</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#3b878279a04dc47d60932cb294d96259">Overview</a><ul>
<li><a href="#34353c345076031b78a95a5d6f747675">Preparation </a></li>
<li><a href="#bd3413f1096defdbbb72de26422494f2">Modify your project</a></li></ul>
</li></ul>
</div>

	<a name="3b878279a04dc47d60932cb294d96259"></a>	<h1>Overview</h1>

	<p>gSOAP is a portable development toolkit for C and C++ <span class="caps">XML</span> Web services and <span class="caps">XML</span> data bindings. Supports <span class="caps">XML</span> auto-serialization of C/C++ data. Includes <span class="caps">WSDL</span>/XSD schema binding tools, stub/skeleton compiler, Web server, <span class="caps">SOAP</span>/XML/MIME streaming, <span class="caps">XML</span>-<span class="caps">RPC</span>. Here is how to use it to build a web service client in Qt.</p>

	<a name="34353c345076031b78a95a5d6f747675"></a>	<h2>Preparation </h2>

	<ul>
		<li>Download and unzip <a href="http://sourceforge.net/projects/gsoap2/">gSOAP package</a> <em>[sourceforge.net]</em>.</li>
	</ul>

	<p>gSOAP package contains pre-built tools in the <code>gsoap/bin</code> directory. </p>

	<ul>
		<li>wsdl2h schema importer</li>
		<li>soap2cpp stub/skeleton generator.</li>
	</ul>

	<p>You require .wsdl and .xsd files of web service to generate c++ stub.</p>

	<a name="bd3413f1096defdbbb72de26422494f2"></a>	<h2>Modify your project</h2>

	<ul>
		<li>First use wsdl2h on .wsdl file it will generate  .h file,  then use soapcpp2 on generated .h file, this will generate .h and .cpp files to be included in Qt project.</li>
	</ul>

	<ul>
		<li>Before using wsdl2h you have to modify “typemap.dat” file, this file is present in ‘gsoap/ws’ directory. Add a line in this file defining namespace of your webservice. Give any name to namespace and copy string from your .wsdl file following the tag.</li>
	</ul>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="sy0">&lt;</span>definitions targetNamespace<span class="sy0">=</span>http<span class="sy0">:</span><span class="co1">//something&gt;</span></div></li>
</ol></div></p>

	<p>Add this line to “typemap.dat” file:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">Anything <span class="sy0">=</span>”http<span class="sy0">:</span><span class="co1">//something”</span></div></li>
</ol></div></p>

	<ul>
		<li>Now run wsdl2h on .wsdl and .xsd files (from command prompt)</li>
	</ul>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">wsdl2h –s &nbsp;<span class="sy0">-</span>t<span class="sy0">&lt;</span>path of typemap.<span class="me1">dat</span><span class="sy0">&gt;</span> –o <span class="sy0">&lt;</span>name of generated .<span class="me1">h</span> file e.<span class="me1">g</span> chatpp.<span class="me1">h</span><span class="sy0">&gt;</span> <span class="sy0">&lt;</span>path and name of .<span class="me1">wsdl</span> file<span class="sy0">&gt;</span></div></li>
</ol></div></p>

	<p>(note .xsd file should be in same directory as .wsdl file)</p>

	<ul>
		<li>Then use soapcpp2 on generated .h file &#40;we assume that name of generated file is chatapp.h&#41;</li>
	</ul>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">soapcpp2 &nbsp;–i chatpp.<span class="me1">h</span></div></li>
</ol></div></p>

	<p>this will generate multiple files</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">soapstub.<span class="me1">h</span></div></li>
<li class="li1"><div class="de1">soapH.<span class="me1">h</span></div></li>
<li class="li1"><div class="de1">soapC.<span class="me1">cpp</span></div></li>
<li class="li1"><div class="de1">soapchatappProxy.<span class="me1">h</span></div></li>
<li class="li2"><div class="de2">soapchatappProxy.<span class="me1">cpp</span></div></li>
<li class="li1"><div class="de1">chatapp.<span class="me1">nsmap</span></div></li>
<li class="li1"><div class="de1">soapchatappsetvice.<span class="me1">h</span></div></li>
<li class="li1"><div class="de1">soapchatappservice.<span class="me1">cpp</span></div></li>
</ol></div></p>

	<p>and an xml file for each method in defined in .wsdl file.</p>

	<ul>
		<li>now add</li>
	</ul>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">soapstub.<span class="me1">h</span></div></li>
<li class="li1"><div class="de1">soapH.<span class="me1">h</span></div></li>
<li class="li1"><div class="de1">soapchatappProxy.<span class="me1">h</span></div></li>
</ol></div></p>

	<p>as headers in to your qt project and then add</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">soapC.<span class="me1">cpp</span></div></li>
<li class="li1"><div class="de1">soapchatppProxy.<span class="me1">cpp</span></div></li>
</ol></div></p>

	<p>as source</p>

	<ul>
		<li>add include path of yor generated file in .pro file of your qt project or simply copy all of generated files to your project directory. Also add path of  “libws2_32.a”  in  your .pro file I my case it is as under</li>
	</ul>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">LIBS &nbsp;<span class="sy0">+=</span> C<span class="sy0">:/</span>NokiaQTSDK<span class="sy0">/</span>mingw<span class="sy0">/</span>lib<span class="sy0">/</span>libws2_32.<span class="me1">a</span></div></li>
</ol></div></p>

	<ul>
		<li>also add stdsoap2.h and stdsoap2.cpp from gsoap directory as header and source in your project.</li>
	</ul>

	<ul>
		<li>now include chatapp.nsmap and chatappProxy.h in your main.cpp.</li>
	</ul>

	<ul>
		<li>make an object of chatappProxy and use it to communicate with webservice.</li>
	</ul>

	<p><em>above method worked for me while using gsoap with NokiaQtSDk on windows xp.</em>
  </p>]]></description>
      <dc:subject>How_to_use_gSOAP_with_Qt_for_Web_Service_Client</dc:subject>
      <dc:date>2012-02-19T12:57:39+00:00</dc:date>
    </item>

    <item>
      <title>Building_Qt_Documentation</title>
      <link>http://developer.qt.nokia.com/wiki/Building_Qt_Documentation</link>
      <guid>http://developer.qt.nokia.com/wiki/Building_Qt_Documentation</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-Documentation-Russian">Русский</a> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-Documentation-Italian">Italiano</a> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-Documentation-Spanish">Spanish</a> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-Documentation-Japanese">日本語</a> <a href="http://developer.qt.nokia.com/wiki/Building-Qt-Documentation-SimplifiedChinese">简体中文</a> </p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#fde8501aef5f1cb43135e705c1ffe0e4">Building Qt Documentation</a><ul>
<li><a href="#7214e4e1961ee4e074d5020fe93b4bb4">Building Qt4 Documentation</a></li></ul>
</li>
<li><a href="#f0054adfad929d21f348c3918b2003ee">Building Qt5 Documentation</a><ul>
<li><a href="#8e138f19e98c9b379385639760a1827d">Building qdoc3</a></li>
<li><a href="#98605d3c7c157f3979feb1c2e3c349ec">Running qdoc3</a><ul>
<li><a href="#db333cf4dbc70622d48a0be916f99383">Using The Qt Build System</a></li>
<li><a href="#f8869c82f62ada5e04eb2ae5e01b5c35">Running qdoc3 Directly</a></li></ul>
</li>
<li><a href="#fae95c635ccd83828e5bdb0cfaecf224">Adding Modules to the Documentation</a><ul>
<li><a href="#02ffed8e088f5603bed875c215fe930c">Points of caution.</a></li></ul>
</li></ul>
</li></ul>
</div>

	<a name="fde8501aef5f1cb43135e705c1ffe0e4"></a>	<h1>Building Qt Documentation</h1>

	<p>For information about writing documentation for Qt, see the <a href="http://developer.qt.nokia.com/wiki/Writing_Qt_Documentation">Writing Qt Documentation</a> page.</p>

	<p>For help on troubleshooting documentation builds, see the <a href="http://developer.qt.nokia.com/wiki/">Troubleshooting_Qt_DocumentationTroubleshooting Qt Documentation</a> page.</p>

	<p>For information about building documentation in the modularized Qt repositories, see the <a href="http://developer.qt.nokia.com/wiki/Building_Qt_5_Documentation">Building Qt 5 Documentation</a> page.</p>

	<a name="7214e4e1961ee4e074d5020fe93b4bb4"></a>	<h2>Building Qt4 Documentation</h2>

	<p>Build Qt as normal.</p>

	<p>Define environment variables for QT_SOURCE_TREE and for QT_BUILD_TREE appropriately. Make sure the <span class="caps">PATH</span> environment variable points to the <em>bin</em> directory containing the <em>qdoc3</em> executable.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd path<span class="sy0">/</span>to<span class="sy0">/</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">qt</span></a></div></li>
<li class="li1"><div class="de1">make docs</div></li>
</ol></div></p>

	<p>For the online docs it may be necessary to use</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd path<span class="sy0">/</span>to<span class="sy0">/</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">qt</span></a></div></li>
<li class="li1"><div class="de1">make online_docs</div></li>
</ol></div></p>

	<p>for later versions of Qt.</p>

	<p>For Windows&#8482; use the nmake utility instead of make. Some Linux systems will require gmake instead of make.</p>

	<p>If you already have Qt compiled (from the <span class="caps">SDK</span>, for example) and want to build some special flavour of the doc, you can call directly qdoc3 (QT_SOURCE_TREE, QT_BUILD_TREE, and <span class="caps">QTDIR</span> must be set appropriately), here for <span class="caps">DITA</span> output: </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qt<span class="sy0">-</span>src</div></li>
<li class="li1"><div class="de1">bin<span class="sy0">/</span>qdoc3 tools<span class="sy0">/</span>qdoc3<span class="sy0">/</span>test<span class="sy0">/</span>qt<span class="sy0">-</span>ditaxml.<span class="me1">qdocconf</span></div></li>
</ol></div></p>

	<a name="f0054adfad929d21f348c3918b2003ee"></a>	<h1>Building Qt5 Documentation</h1>

	<a name="8e138f19e98c9b379385639760a1827d"></a>	<h2>Building qdoc3</h2>

	<p>qdoc3 is built during a normal build of Qt because it is needed to generate the Qt documentation. This means that, for many developers, qdoc3 is installed alongside the other Qt tools. </p>

	<p>Copy over the qdoc3 executable from qt5/qtbase/bin to qt5/qtdoc/tools/qdoc3/ because that is where the Makefile expects it to be.</p>

	<a name="98605d3c7c157f3979feb1c2e3c349ec"></a>	<h2>Running qdoc3</h2>

	<p>There are two ways to build Qt documentation.</p>

	<a name="db333cf4dbc70622d48a0be916f99383"></a>	<h3>Using The Qt Build System</h3>

	<p>At the command line, enter the root directory of the build tree and invoke the <em>docs</em> build rule.</p>

	<p>You will first need to go to the qtdoc directory located under qt5.</p>

	<p>For example, on Linux/Unix platforms to make Creator style documentation:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qt5<span class="sy0">/</span>qtdoc</div></li>
<li class="li1"><div class="de1">make docs</div></li>
</ol></div></p>

	<p>or for the online style:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qt5<span class="sy0">/</span>qtdoc</div></li>
<li class="li1"><div class="de1">make online_docs</div></li>
</ol></div></p>

	<p>On Windows, you may be using the native <em>nmake</em> tool:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">cd qt5<span class="sy0">/</span>qtdoc</div></li>
<li class="li1"><div class="de1">nmake docs</div></li>
</ol></div></p>

	<a name="f8869c82f62ada5e04eb2ae5e01b5c35"></a>	<h3>Running qdoc3 Directly</h3>

	<p>Under construction.</p>

	<a name="fae95c635ccd83828e5bdb0cfaecf224"></a>	<h2>Adding Modules to the Documentation</h2>

	<p>Here we will add a module, in this case QtLocation, to the Qt5 documentation. We will use the default name of the repository &#8216;qt5&#8217; in the example.</p>

	<p>There should already be an entry in qt5/qtdoc/doc/doc.pri in the <span class="caps">MODULES</span> list for your module, if not it is easily added.</p>

	<p>In the directory qt5/qtdoc/doc/config there is a directory &#8216;modules&#8217;. There should be a qdocconf file for each module.</p>

	<p>The location one is qtlocation.qdocconf. This is just a list of specifications on the locations of header, source, example and image directories. It is a simple task to copy, paste and edit one to your own needs.</p>

	<p>The environment variable that is used to identify the location of the module source, eg QT_LOCATION_SOURCES is constructed in the qtdoc tree from the location specified in the module&#8217;s source tree. These environment variables are then hardcoded into the qdocconf files in qt5/qtdoc/doc/config/modules, which explains the contents of qtlocation.qdocconf.</p>

	<p>For QtLocation, the above is simply background since location is in the list of modules and a qtlocation.qdocconf file has been written.</p>

	<p>To add documentation source to location we have to add the files <em>location.qdoc</em> and <em>qlandmarks.qdoc</em> to qt5/qtlocation/doc/src. Also we need to create and populate the &#8216;examples&#8217;, &#8216;plugins&#8217; and &#8216;snippets&#8217; directories which will contain the location specific examples, plugin docs and snippet files.</p>

	<p>Also copy across the related examples to the &#8216;examples&#8217; qt5/qtlocation/examples directory. These will be the examples that contain snippets used in the documentation.</p>

	<p>Next we add our Location classes to the Modules page (this does not link the overview however, only a link to the classes in the module).</p>

	<p>In qt5/qtdoc/doc/src/modules.qdoc add the following to the table</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">\row \o \l<span class="br0">&#123;</span>Location API<span class="br0">&#125;</span><span class="br0">&#123;</span>QtLocation<span class="br0">&#125;</span> \o Classes <span class="kw1">for</span> Location and Landmarks</div></li>
</ol></div></p>

	<p>To link the module overview we have to simply add</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">\ingroup technology<span class="sy0">-</span>apis</div></li>
</ol></div></p>

	<p>to the location.qdoc and qlandmarks.qdoc, this will mean that the module link will appear in the Technology <span class="caps">API</span>s page accessible via the sidebar or the front page (the latter has an incorrect link which I will fix).</p>

	<a name="02ffed8e088f5603bed875c215fe930c"></a>	<h3>Points of caution.</h3>

	<p>qdoc3 does not understand two pages with the same title and html output page correctly. When adding documentation one should therefore be careful to not call the index page for the add-on module index.html when it should be part of the complete Qt documentation, since this might overwrite the index page for the whole of the documentation (qdoc3 overwrites entriers already in its internal list of pages, therefore the last page found will be the displayed one)</p>]]></description>
      <dc:subject>Building_Qt_Documentation</dc:subject>
      <dc:date>2012-02-18T19:00:21+00:00</dc:date>
    </item>

    <item>
      <title>PySide_QtQuick_Tutorials</title>
      <link>http://developer.qt.nokia.com/wiki/PySide_QtQuick_Tutorials</link>
      <guid>http://developer.qt.nokia.com/wiki/PySide_QtQuick_Tutorials</guid>
      <description><![CDATA[<a name="5a11418ffbc1eeea20dd6083d0aa7c51"></a>	<h1>PySide/QtQuick Tutorials</h1>

	<p>In this wiki page, we have sorted out some tutorials structured by rough experience levels. So we have tutorials for absolute beginners, for intermediate PySide developers and for the more advanced ones who are just searching for simple solutions for their complex problems.</p>

	<a name="f8aeca738336d6b030e34ad9ecf80d05"></a>	<h2>Beginner tutorials</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Hello_World_in_PySide_and_QtQuick">An Hello World with PySide and Qt Quick</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySide_and_QML_Playground">PySide_and_QML_Playground</a></li>
	</ul>

	<a name="f3c96a700473da01afed331649809308"></a>	<h2>Intermediate tutorials</h2>

	<ul>
		<li><a href="http://lynxline.com/superhybrids-part-2-now-qt-pyside/" title="Site is down">SuperHybrids part 2, now Qt + PySide</a> <em>[lynxline.com]</em>
	<ul>
		<li>I am not sure is this belongs in QtQuick section as it has nothing to do with <span class="caps">QML</span>.</li>
		<li><a href="http://web.archive.org/web/20110725160123/http://lynxline.com/superhybrids-part-2-now-qt-pyside/">Wayback Machine Formatted Mirror</a> <em>[web.archive.org]</em></li>
		<li><a href="http://webcache.googleusercontent.com/search?q=cache:lynxline.com/superhybrids-part-2-now-qt-pyside/&amp;strip=1">Google Text-Only Mirror</a> <em>[webcache.googleusercontent.com]</em></li>
	</ul></li>
	</ul>

	<a name="d7bb894d248f19d64af1b732744bef2a"></a>	<h2>Advanced tutorials</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Selectable_list_of_Python_objects_in_QML">Selectable list of Python objects in <span class="caps">QML</span></a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Multi-selection_lists_in_Python_with_QML">Multi selection lists in Python with <span class="caps">QML</span></a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Defining_and_using_constants_from_PySide_in_QML">Defining and using constants from PySide in <span class="caps">QML</span></a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Using_QtWebKit_and_QML_with_PySide">Using QtWebKit and <span class="caps">QML</span> with PySide</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Updating_QML_content_from_Python_threads">Updating <span class="caps">QML</span> content from Python threads</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Utilizing_Qt_Quick_Colibri_in_PySide">Utilizing Qt Quick Colibri in PySide</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Filling_and_reading_QML_UI_forms_from_Python">Filling and reading <span class="caps">QML</span> UI forms from Python</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Auto-generating_QObject_from_template_in_PySide">Auto generating QObject from template in PySide</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Using_QtMobility_sensors_and_QML_from_PySide">Using QtMobility sensors and <span class="caps">QML</span> from PySide</a></li>
	</ul>]]></description>
      <dc:subject>PySide_QtQuick_Tutorials</dc:subject>
      <dc:date>2012-02-18T18:51:55+00:00</dc:date>
    </item>

    <item>
      <title>QtResources_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/QtResources_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/QtResources_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/QtResources">English</a> <a href="http://developer.qt.nokia.com/wiki/QtResources-SimplifiedChinese">简体中文</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#e1786b5fae4c83bb54c3f8cb4359a31f">Общ преглед</a></li>
<li><a href="#8a1a509e27352f56c17b520d3ca24687">Как работи</a></li>
<li><a href="#de7bdb74ed1ae35acb8db45280ac83d3">Q_INIT_RESOURCE</a></li>
<li><a href="#56cbdb1de50981f927e7eba5ffbe71ad">Достъпване на ресурси</a></li>
<li><a href="#878f03b87d919cda17ce5a4acde4f036">Именни пространства за ресурси</a></li></ul>
</div>

	<p>Написано от : Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="e1786b5fae4c83bb54c3f8cb4359a31f"></a>	<h1>Общ преглед</h1>

	<p><em>Qt Resources</em> предоставя платформено независим механизъм за вкарване на произволни бинарни данни, включително изображения и звуци, като част от изпълнимият файл на приложението. Вижте <a href="http://doc.qt.nokia.com/snapshot/resources.html">документацията на ресурсите</a> <em>[doc.qt.nokia.com]</em> за по-подробна информация.  </p>

	<p>По отношение на имплементацията, ресурсите в Qt нямат нищо общо с <a href="http://msdn.microsoft.com/en-us/library/ms648007.aspx"><span class="caps">RES</span> файловете</a> <em>[msdn.microsoft.com]</em> на Windows или <a href="http://en.wikipedia.org/wiki/Resource_fork">resource forks</a> <em>[en.wikipedia.org]</em> on Mac OS X.</p>

	<a name="8a1a509e27352f56c17b520d3ca24687"></a>	<h1>Как работи</h1>

	<p>Ресурсните файлове (i.e .qrc files) са <span class="caps">XML</span>-и, които описват кои файлове трябва да се пакетират в крайният бинарен файл. Ресурсният компилатор <em>rcc</em> обхожда <span class="caps">XML</span>-а и генерира C/C++ код. Този генериран код съдържа C структура, която съдържа суровите данни на файловете, който се намират в .qrc. След това тези C-структури се събират в друга C-структура, за да формират дървовидна структура, така че файловете да могат да се наредят в йерархии. Детайлите за тази структура сами по себе си не са много интересни, за това и не са описани тук. С опцията -_compressed_ на rcc, данните в структурите се компресират със zlib (по подразбиране, компресирането е изключено).</p>

	<p>C-структурите трябва да се регистрират в Qt, за да може то да знае за тях. Номера е, че в края на всеки генериран от rcc C++ файл, rcc слага извикване на qRegisterResourceData(), което регистрира C структурата в системата за ресурси на Qt. Чрез използването на <em>подхода за конструктурна функция</em>, qRegisterResourceData() се извиква преди main(). <em>Подхода за конструктурната функция</em> е използването на глобална статична променлива, която се инициализира като се извиква функция.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#ifndef Q_CONSTRUCTOR_FUNCTION</span></div></li>
<li class="li1"><div class="de1"><span class="co2"># define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \</span></div></li>
<li class="li1"><div class="de1"><span class="co2">&nbsp; &nbsp;static const int AFUNC ## __init_variable__ = AFUNC();</span></div></li>
<li class="li1"><div class="de1"><span class="co2"># define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)</span></div></li>
<li class="li2"><div class="de2"><span class="co2">#endif</span></div></li>
</ol></div></p>

	<p>В края на генерирания от rcc C++ файл, съдържа нещо подобно на:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw4">int</span> qInitResources_images<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; qRegisterResourceData<span class="br0">&#40;</span><span class="nu12">0x01</span><span class="sy0">,</span> qt_resource_struct<span class="sy0">,</span> qt_resource_name<span class="sy0">,</span> qt_resource_data<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">1</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Q_CONSTRUCTOR_FUNCTION<span class="br0">&#40;</span>qInitResources_images<span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>Тъй като статичните променливи се инициализират преди извикаването на main(), всички ресурси автоматично се регистрират преди същинската програма да стартира.</p>

	<a name="de7bdb74ed1ae35acb8db45280ac83d3"></a>	<h1>Q_INIT_RESOURCE</h1>

	<p>Трикът с конструкторната функция работи само ако генерирания C++ файл е компилиран и вързан за приложението директно. Ако ресурсите се използват в статична библиотека и тя е свързана с приложението, конструкторната функция никога няма да се извика. Това е в природата на C/C++ свръзването &#8211; функциите и променливите в библиотеките, които не се използват/извикват от крайната програма се премахват от крайният бинарен код ( оптимизират се). Ако ресурсите са в споделена библиотека, тогава конструкторната функция се извиква. Обаче, повечето платформи зареждат споделените библиотеки при нужда и конструктурната функция се извиква само когато библиотеката се зарежда. Последствието от това е, че всички ресурси в плъгини, които се използват в главната програма, няма да бъдат намерени от Qt, докато плъгина не бъде зареден &#8211; това не е проблем, ако ресурсиоте от споделената библиотека се изпозлват само в нея. Обърнете внимание на това, че достъпването на ресурси от споделената библиотека в главното приложение не предизвиква зареждането и, тъй като никакви символи не се експортират от <span class="caps">QRC</span> системата.</p>

	<p>Решението на този проблем е да се използва генерирана променлива( от <span class="caps">AFUNC</span> ## <i>init_variable</i> по-горе) или да се извика генерираната функция qInitResource_images(). Макросът Q_INIT_RESOURCE съществува с тази цел и се <em>изисква, когато имате ресурси в статична или споделена библиотека</em>.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#define Q_INIT_RESOURCE_EXTERN(name) \</span></div></li>
<li class="li1"><div class="de1"><span class="co2">&nbsp; &nbsp; extern int qInitResources_ ## name();</span></div></li>
</ol></div></p>

	<p>Макроса по-горе обикновено се слага в началото на main() за всеки qrc файл.</p>

	<a name="56cbdb1de50981f927e7eba5ffbe71ad"></a>	<h1>Достъпване на ресурси</h1>

	<p>QFile, QDir, QPixmap и т.н. могат да достъпват qrc файлове. Целият достъп до файлове в Qt минава през <a href="http://doc.trolltech.com/4.6/qabstractfileengine.html">QAbstractFileEngine</a> <em>[doc.trolltech.com]</em>. QResource регистрира подклас на QAbstractFileSystemEngine при стартиране, който предоставя валидна система за достъп до файлове (през QAbstractFileEngine::create), когато името на файла започва с &#8220;:&#8221;.</p>

	<a name="878f03b87d919cda17ce5a4acde4f036"></a>	<h1>Именни пространства за ресурси</h1>

	<p>Когато използвате ресурси в плъгини, ресурсните пътища трябва да бъдат именовани. Използването на името на плъгина за именоване на ресурсното пространство е добра техника. За пример, <emcite="/plugin_name/resourcenam">e</em>. Ако съществуващ път до ресурси е регистриран втори път с различни данни, той се игнорира и се запазва първия.</p>]]></description>
      <dc:subject>QtResources_Bulgarian</dc:subject>
      <dc:date>2012-02-18T12:21:56+00:00</dc:date>
    </item>

    <item>
      <title>UsingQStringEffectively</title>
      <link>http://developer.qt.nokia.com/wiki/UsingQStringEffectively</link>
      <guid>http://developer.qt.nokia.com/wiki/UsingQStringEffectively</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/UsingQStringEffectively-SimplifiedChinese">简体中文</a> <a href="http://developer.qt.nokia.com/wiki/UsingQStringEffectively_Bulgarian">Български</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#019362453f8359b194a75838f9491d2d">QLatin1String : Avoid hidden mallocs in operator "=="</a></li>
<li><a href="#24d9f4498328502b7189c77c6404fd69">QStringRef : String manipulation without the malloc</a></li>
<li><a href="#03463588ef2f8be9633467488034ef2f">QString::reserve and QString::squeeze</a></li>
<li><a href="#6c7f5f5135b4092d900571aab77097fd">QStringBuilder : Fast QString concatenation</a></li>
<li><a href="#dfae34a8d154b2d8bbfd812ee51915b6">QStringMatcher : Fast string matching</a></li></ul>
</div>

	<p>Written By : Girish Ramakrishnan, ForwardBias Technologies</p>

	<p>This page explains the purpose of various QString related classes.</p>

	<a name="019362453f8359b194a75838f9491d2d"></a>	<h1>QLatin1String : Avoid hidden mallocs in operator &#8220;==&#8221;</h1>

	<p>Creating a QString from a C-string may involve a malloc. For example, there is possibly a hidden-malloc cost in the following code.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>fruit <span class="sy0">==</span> <span class="st0">&quot;apple&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="co1">// possibly hidden malloc</span></div></li>
</ol></div></p>

	<p>QString provides a QString::operator==(const char *) overload for comparison with C-strings. As explained in <a href="http://developer.qt.nokia.com/wiki/QtStrings/">QtString</a> <em>[developer.qt.nokia.com]</em>, the encoding of C-strings is determined using QTextCodec::setCodecForCStrings(). When no special encoding is set, Qt performs the above comparison by providing a specialized function that compares a Unicode string (fruit) and the Latin-1 string (&#8216;apple&#8217;). This comparison is fast and requires no mallocs.</p>

	<p>However, when QTextCodec::setCodecForCString is set, &#8220;apple&#8221; gets converted into a QString using QString::fromAscii(). This means that QString will allocate memory for the string &#8220;apple&#8221; and creates a deep copy of the C-style string before performing the comparison!</p>

	<p>Application developers set QTextCodec::setCodecForCString() in main() without realizing that this has the side-effect of a malloc for every single C-style string comparison.</p>

	<p>Since comparisons with Latin-1 C-strings are very common in programs, Qt provides a special class called QLatin1String that just holds a pointer to a Latin-1 encoded C-string. In addition, QString provides a QString::operator==(const QLatin1String &amp;) overload that calls the specialized function that compares the Unicode string and Latin1-string. We can make the above code assuredly fast by writing it instead as,<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>fruit<span class="sy0">==</span> <a href="http://developer.qt.nokia.com/doc/QLatin1String.html"><span class="kw5">QLatin1String</span></a><span class="br0">&#40;</span><span class="st0">&quot;apple&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="co1">// fast and mentions encoding</span></div></li>
</ol></div></p>

	<p>In Qt&#8217;s own code, all C-strings comparisons use QLatin1String since the application can choose an arbitrary codec for C-strings.</p>

	<a name="24d9f4498328502b7189c77c6404fd69"></a>	<h1>QStringRef : String manipulation without the malloc</h1>

	<p>QString has various methods for string manipulations like mid(), left(), right(). All of them create a new QString and hence a malloc/deep copy of data in an existing QString. Instead, QString::midRef(), QString::leftRef() and QString::rightRef() can be used to obtain a QStringRef. A QStringRef is a reference of a portion of a QString. QString also provides many overloads like QString::operator==(const QStringRef &amp;) for optimal use with QStringRef.</p>

	<a name="03463588ef2f8be9633467488034ef2f"></a>	<h1>QString::reserve and QString::squeeze</h1>

	<p>It&#8217;s better to call QString::reserve to allocate extra memory in advance so that every call to QString::append() does not result in a malloc. Extra memory can be reclaimed using QString::squeeze.</p>

	<a name="6c7f5f5135b4092d900571aab77097fd"></a>	<h1>QStringBuilder : Fast QString concatenation</h1>

	<p>The code below requires atleast 2 mallocs. First a malloc to store the result of &#8220;(&#8221; + type. And then another malloc for appending the &#8220;)&#8221;. The number of mallocs increases with each addition of &#8220;+&#8221; operator.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>foo.<span class="me1">startsWith</span><span class="br0">&#40;</span><span class="st0">&quot;(&quot;</span> <span class="sy0">+</span> type <span class="sy0">+</span> <span class="st0">&quot;)&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>The additional mallocs can be avoided if the length of the final QString is known in advance. Qt 4.6 introduces an internal class called QStringBuilder that &#8220;reserves&#8221; memory for a concatenation chain in a single shot. It does so by having each of the + operations above return a different class (not QString anymore). This class keeps track of the string&#8217;s that are being appended and the required memory at each step. At the final step, when the concatenation operation gets converted into a QString it allocates memory in a single shot and copies all the strings in the chain one after another. This feature can be enabled by including &lt;QtCore/QStringBuilder&gt;.  and using use the operator &#8216;%&#8217; instead of &#8216;+&#8217;. One would now write,<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>foo.<span class="me1">startsWith</span><span class="br0">&#40;</span><span class="st0">&quot;(&quot;</span> <span class="sy0">%</span> type <span class="sy0">%</span> <span class="st0">&quot;)&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>&#8216;+&#8217; can be used instead of &#8216;%&#8217; by defining QT_USE_QSTRINGBUILDER. See <a href="http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#more-efficient-string-construction">Fast concatenation</a> <em>[developer.qt.nokia.com]</em> for more details</p>

	<a name="dfae34a8d154b2d8bbfd812ee51915b6"></a>	<h1>QStringMatcher : Fast string matching</h1>

	<p>QStringMatcher can be used to look for a string repetitively in many strings or in the same string many times. It uses &#8220;Boyer-Moore string search algorithm&#8221;:<a href="http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm">http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm</a> to perform fast searches.</p>]]></description>
      <dc:subject>UsingQStringEffectively</dc:subject>
      <dc:date>2012-02-17T11:35:27+00:00</dc:date>
    </item>

    <item>
      <title>QML Application Structuring Approaches</title>
      <link>http://developer.qt.nokia.com/wiki/QML&#45;Application&#45;Structuring&#45;Approaches</link>
      <guid>http://developer.qt.nokia.com/wiki/QML&#45;Application&#45;Structuring&#45;Approaches</guid>
      <description><![CDATA[<p><strong>English</strong><br />
<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#d966cfff907ae170aa3a1ddbe8c622ca">QML Application Structuring Approaches</a><ul>
<li><a href="#5b064a7d212bfe223b87206cf978fd16"> Introduction</a></li>
<li><a href="#7b6c2d7b667e175d6279860b6db7a299">Component Element Definition</a></li>
<li><a href="#c219367c2861b18f0dc14e28533747bf">Loader Element Definition</a></li>
<li><a href="#c10a887c523b364ad551a1fc4a8a2c15">Component Element vs. Loader Element</a></li>
<li><a href="#3a3dc4fa6e1a4680eab98485c4317812">Loader Element Use Cases</a><ul>
<li><a href="#958f7abb18000a6768d6ad5b3f170d08">Simple Wizard Template</a></li>
<li><a href="#d7fbb3c1ae6af2b913f8f29252ad7eee">More Complex Navigation </a></li>
<li><a href="#fa8a15c8458b3a67917235ce87dc7082">Loader and Component Together</a></li>
<li><a href="#1d69f33c86ae4fbd0923907e79f4f399">Loader and Inline Component</a></li></ul>
</li></ul>
</li></ul>
</div></p>

	<a name="d966cfff907ae170aa3a1ddbe8c622ca"></a>	<h1><span class="caps">QML</span> Application Structuring Approaches</h1>

	<a name="5b064a7d212bfe223b87206cf978fd16"></a>	<h2> Introduction</h2>

	<p>A common approach to deal with a complex application is to decompose it in several smaller units. This leads to better structuring of application and more productive development process as a whole. <span class="caps">QML</span> offers two constructs that service this approach – <em>Component</em> and <em>Loader</em> elements. Roughly speaking, the both elements bring similar functionality. But the ways they do this are different. We may refer to the <em>Component</em> approach as static one and the <em>Loader</em> approach as dynamic one. We first re-call <em>Component</em> and <em>Loader</em> definitions, than compare the two approaches and in the main part of this article describe several <em>Loader</em> element use cases. There are two other approaches to structure a <span class="caps">QML</span> application also – dynamic creation of objects and module importing. They are beyond the scope of this article.</p>

	<a name="7b6c2d7b667e175d6279860b6db7a299"></a>	<h2>Component Element Definition</h2>

	<p>A <span class="caps">QML</span> component is a separate, autonomous unit that contains other <span class="caps">QML</span> elements. It could be defined in two modes – as an inline unit in a <span class="caps">QML</span> file or as a separate <span class="caps">QML</span> file. The main point with <span class="caps">QML</span> component is that it could be reused many times trough its very convenient interface. For more details about <em>Component</em> syntax and interface consult the <a href="http://doc.qt.nokia.com/4.7/qml-component.html">documentation.</a> <em>[doc.qt.nokia.com]</em></p>

	<p>How does the <em>Component</em> element support application code structuring and particularly its decomposition? In case of component file it is obvious – the application is split in several components. They are included in the main file and instantiated via their interfaces, for example like this:</p>

	<p><span class="caps">QML</span> File</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">…</div></li>
<li class="li1"><div class="de1">Banner <span class="br0">&#123;</span> &nbsp;<span class="co1">//The component file Banner.qml, located in the directory of the </span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//QML File is instantiated here</span></div></li>
<li class="li1"><div class="de1">id<span class="sy0">:</span>ban1</div></li>
<li class="li2"><div class="de2">color<span class="sy0">:</span>”red”</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">…</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">AnotherComponent <span class="br0">&#123;</span> &nbsp;<span class="co1">//Here another component is instantiated</span></div></li>
<li class="li2"><div class="de2">…</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">…</div></li>
<li class="li1"><div class="de1">Banner <span class="br0">&#123;</span> <span class="co1">//Here we use the same component file Banner.qml. The instantiated component is </span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//different from ban1 – different id,</span></div></li>
<li class="li2"><div class="de2">id<span class="sy0">:</span>ban2 &nbsp;<span class="co1">//property color has different value, etc. </span></div></li>
<li class="li1"><div class="de1">color<span class="sy0">:</span>”lightblue”</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">…</div></li>
</ol></div></p>

	<p>Including of the component means that we get an instance of the component viewed as a template. The basic component is used to generate instances only and they do not depend anymore on it. We may have several instances and they behavior independently, treated like basic <span class="caps">QML</span> elements. Note that <em>Component</em> interface allows to re-define component properties &#8211; predefined ones as well as defining new ones.  This is the case of the <em>color</em> property in the snippet above.  We could even just instantiate the component and not alter any property.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">…</div></li>
<li class="li1"><div class="de1">Banner <span class="br0">&#123;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">…</div></li>
</ol></div></p>

	<p>We may have many instances of <em>Banner</em> component provided that they have different <em>id</em>. </p>

	<p>By now we are considering properties defined at the top level of the component file. What about siblings’/children’ properties in a component file? Let us consider the following case:</p>

	<p><em>ExampleOne.qml</em> &#8211; Component file </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// This component file is used in componentScope.qml file</span></div></li>
<li class="li1"><div class="de1"><span class="co1">// The point is how to have access to color property out of the scope of Text element </span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li2"><div class="de2">Rectangle <span class="br0">&#123;</span> &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">300</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property alias nameTextTop<span class="sy0">:</span>nameText <span class="co1">// This alias is defined at top level and </span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// bound to Text element</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; Text<span class="br0">&#123;</span>id<span class="sy0">:</span>nameText</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;blue &quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span><span class="st0">&quot;Some text fragment&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>componentScope.qml</em> – It is using component ExampleOne</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// The component ExampleOne is instantiated and its color property is change to red</span></div></li>
<li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; ExampleOne<span class="br0">&#123;</span>id<span class="sy0">:</span>instance</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; nameTextTop.<span class="me1">color</span><span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>As you see if we want to re-define the property <em>color</em> of <em>nameText</em> child we have to make it visible at the top level. To get this we define an alias of the <em>nameText</em> at the top level. This alias is re-defined in <em>componentScope.qml file</em>. </p>

	<p>Could we develop more complex structures with components? For instance, could we have nested components? By nested components we mean that a component contains another component. Structures like these are acceptable:</p>

	<p><em>nestedComponents.qml</em> &#8211; Main file </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// Main file uses a component – Comp1. It in turn applies a nested component Comp2.</span></div></li>
<li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Comp1<span class="br0">&#123;</span><span class="br0">&#125;</span> <span class="co1">//This component has a nested component Comp2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">centerIn</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span> <span class="st0">&quot;Top Level - we use a component Comp1&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Comp1.qml</em> &#8211; First level component file </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1"><span class="co1">//First level component Comp1.qml</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Comp2<span class="br0">&#123;</span><span class="br0">&#125;</span> <span class="co1">// This component becomes part of Co&quot;mp1</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="st0">&quot;:http://doc.qt.nokia.com/4.7/qml-component.html</span></div></li>
</ol></div></p>

	<p><em>Comp2.qml</em> &#8211; Second level component file </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1"><span class="co1">//This is a component we nest in another component Comp1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">50</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">40</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;green&quot;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>The inline definition syntax of the component element is very similar to this one of other <span class="caps">QML</span> elements. It starts with a key word <em>Component</em> followed by element block (represented by <em>&#123; &#125;</em> pair). Within the block you may define and nest other <span class="caps">QML</span> elements – refer to Nokia <a href="http://doc.qt.nokia.com/4.7/qml-component.html">documentation</a> <em>[doc.qt.nokia.com]</em>.</p>

	<p>On the other hand, inline <em>Component</em> offers other kind of structuring. It encapsulates a piece of <span class="caps">QML</span> code that could be assigned as a property value of other <span class="caps">QML</span> elements. Particularly this mechanism is used in the definition of the <em>Loader</em> element – see the next section. This kind of structuring is sometimes referred as aggregation. An example how inline <em>Component</em> could be utilized is demonstrated in section <strong>Loader and Inline Component</strong>.</p>

	<a name="c219367c2861b18f0dc14e28533747bf"></a>	<h2>Loader Element Definition</h2>

	<p><em>Loader</em> element serves as a handler, which loads dynamically a <span class="caps">QML</span> unit formed as a separate <span class="caps">QML</span> file or inline component. Dynamically means that the <span class="caps">QML</span> unit to be loaded is determined at run-time, for example if a mouse button is clicked. The loaded unit is described as value of <em>source</em> or <em>sourceComponent</em> property of the <em>Loader</em>. The <em>source</em> value is a <span class="caps">URL</span> value – the path to <span class="caps">QML</span> file to be loaded. The <em>sourceComponent</em> value is <em>id</em> name of an inline component. Where can we bind values to these properties? The rule is: at places where the <em>Loader id</em> name is visible. In the following sections you see many examples of implementation of this rule. For more information on Loader see <a href="http://doc.qt.nokia.com/4.7/qml-loader.html#details">documentation</a> <em>[doc.qt.nokia.com]</em>.</p>

	<p>One interesting point is how the loaded <span class="caps">QML</span> unit could be accessed. The <em>Loader</em> element has a default property <em>item</em>. It is read-only and has <em>Item</em> type. In other words, loaded <span class="caps">QML</span> unit is a <span class="caps">QML</span> <em>Item</em> element. We recall that it is not visible and serves to group other <span class="caps">QML</span> elements. An illustrating snippet on item property follows:</p>

	<p><em>LoaderItem.qml</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// QML file Page.qml is loaded by Loader top. Its color property is red</span></div></li>
<li class="li1"><div class="de1"><span class="co1">// Using Loader item property the color property is changed to blue</span></div></li>
<li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Loader <span class="br0">&#123;</span>id<span class="sy0">:</span>top <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span>Component.<span class="me1">onCompleted</span><span class="sy0">:</span>top.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;Page.qml&quot;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">centerIn</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span> <span class="st0">&quot;Hello World&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span>top.<span class="me1">item</span>.<span class="me1">color</span><span class="sy0">=</span><span class="st0">&quot;blue&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Page.qml</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>We could set up <em>source</em> or <em>sourceComponent</em> properties in the <em>Loader</em> definition. Now the <em>Loader</em> element is processed like any other <span class="caps">QML</span> element and its target will be rendered. In this case the behavior is similar to the one of component element. But note that we may change programmatically properties values of <em>source</em> or <em>sourceComponent</em> at a later time.  </p>

	<a name="c10a887c523b364ad551a1fc4a8a2c15"></a>	<h2>Component Element vs. Loader Element</h2>

	<p>Now we are going to compare component file and <em>Loader</em> element. They both offer similar functionality, but differ in ways they are applied.</p>

	<p>In case of a component file we have the following process. We declare the component (rather its interface) in a fixed way in the main file for example. <span class="caps">QML</span> parser immediately checks if a component file with the name as in component declaration exists. The parser searches in the directory where is placed the file. </p>

	<p>The <em>Loader</em> acts a bit differently. When a <span class="caps">QML</span> file containing a <em>Loader</em> element is parsed, the <em>Loader</em> constructs itself like any other <span class="caps">QML</span> element. The <em>Loader</em> could define the source destination of the file to be loaded or not. In the first case the file is loaded. In the second case this is postponed to the moment we define the source destination of the file in a script element for example. Note that in case of <em>source</em> property we may point to a file located anywhere on our local computer or on the Internet. If we have many <span class="caps">QML</span> entities that are not needed permanently, there is no need to keep them in memory – rather load them as they are necessary.  This leads to a better structuring of the application and more efficient computer memory management. Be aware that any consequent activation of a <em>Loader</em> destroys the previously loaded items.  If we set an empty string as <em>source</em> property value or undefined value to <em>sourceComponent</em> property, the memory used by the <em>Loader</em> is released.</p>

	<p>Because the file to be loaded by a <em>Loader</em> could be determined in run-time, the <em>Loader</em> approach is referred to as dynamic one. The component approach is called static one.</p>

	<p>Combining loaders, components and other <span class="caps">QML</span> elements it is important to understand the hierarchy of elements and how they overlap each other. Let us create a demo example, which will illustrate <span class="caps">QML</span> elements rendering hierarchy. We are considering a <span class="caps">QML</span> main file that has two <em>Loaders</em>, one component and other standard <span class="caps">QML</span> elements. We re-define the <em>z</em> property of elements to control their overlapping.</p>

	<p><em>elementHierarchy.qml</em> – main file</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>first</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;lightblue&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; Loader <span class="br0">&#123;</span>id<span class="sy0">:</span>newLoad</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span>id<span class="sy0">:</span>textInner</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;z<span class="sy0">:</span><span class="nu0">3</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;text<span class="sy0">:</span> <span class="st0">&quot;Sample text with z=7 property &quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>second</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span><span class="nu0">100</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; z<span class="sy0">:</span><span class="nu0">2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">80</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;pink&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Text <span class="br0">&#123;</span>text<span class="sy0">:</span><span class="st0">&quot;<span class="es1">\n</span><span class="es1">\n</span>\Component <span class="es1">\n</span> with z=2&quot;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; CompNew<span class="br0">&#123;</span>id<span class="sy0">:</span>far</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;x<span class="sy0">:</span><span class="nu0">20</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">20</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Loader<span class="br0">&#123;</span>id<span class="sy0">:</span>loadSecond</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; source<span class="sy0">:</span><span class="st0">&quot;secondComp.qml&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>dummy</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span><span class="nu0">80</span><span class="sy0">;</span>height<span class="sy0">:</span><span class="nu0">40</span><span class="sy0">;</span>x<span class="sy0">:</span><span class="nu0">140</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">80</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;gray&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Component.<span class="me1">onCompleted</span><span class="sy0">:</span><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; newLoad.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;firstLoader.qml&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>firstLoader.qml</em> – file loaded by <em>newLoad Loader</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; y<span class="sy0">:</span><span class="nu0">30</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>secondComp.qml</em> &#8211; loaded by <em>loadSecond Loader</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">40</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">45</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;green&quot;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>CompNew.qml</em> – component file</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>comp</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;yellow&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span>text<span class="sy0">:</span><span class="st0">&quot;CompNew&quot;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>The next picture illustrates how <span class="caps">QML</span> elements are displayed and overlapping. As a rule elements are rendered in the order they are defined in the main file. In the snippets above <em>z</em> property is changed for text element <em>textInner</em> (z=3) and for rectangle element <em>second</em> (z=2) and they are rendered at the top element hierarchy.</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/elementsHier488.jpg" alt="" /></p>

	<p>You may experiment changing <em>z</em> property.</p>

	<a name="3a3dc4fa6e1a4680eab98485c4317812"></a>	<h2>Loader Element Use Cases</h2>

	<a name="958f7abb18000a6768d6ad5b3f170d08"></a>	<h3>Simple Wizard Template</h3>

	<p>Our application consists of several pages (3 in the snippet bellow), each of them formatted as a separate <span class="caps">QML</span> file. These files could be located in different directories, but for simplicity we suppose they reside in the directory where is located our main file. Each page has its own <em>Loader</em> element and when a <em>Click me</em> button is pressed the <em>Loader</em> loads a next wizard page.</p>

	<p><em>wizardSimple.qml</em> – main file </p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>top</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span><span class="nu0">360</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; Loader <span class="br0">&#123;</span>id<span class="sy0">:</span>main<span class="br0">&#125;</span> <span class="co1">//Declaration of a Loader. It will be activated later.</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;text<span class="sy0">:</span> <span class="st0">&quot;Main file&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Button<span class="br0">&#123;</span>id<span class="sy0">:</span>buttonMain</div></li>
<li class="li2"><div class="de2">&nbsp;<span class="co1">//Position the button in top rectangle</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">bottom</span><span class="sy0">:</span>top.<span class="me1">bottom</span><span class="sy0">;</span> anchors.<span class="me1">right</span><span class="sy0">:</span> top.<span class="me1">right</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span>main.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;Page1.qml&quot;</span><span class="sy0">;</span> <span class="co1">//Load a new page</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buttonMain.<span class="me1">z</span><span class="sy0">=-</span><span class="nu0">1</span> <span class="co1">//Hide button</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Page1.qml</em> – first wizard page</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>page1Container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">300</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">40</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">40</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;pink&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Loader<span class="br0">&#123;</span>id<span class="sy0">:</span>page1<span class="br0">&#125;</span> <span class="co1">//Declaration of a new Loader element</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text<span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span><span class="st0">&quot;First page loaded&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Button<span class="br0">&#123;</span>id<span class="sy0">:</span>buttonPage1</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="co1">//Position the button in page1Container rectangle</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">bottom</span><span class="sy0">:</span>page1Container.<span class="me1">bottom</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">right</span><span class="sy0">:</span> page1Container.<span class="me1">right</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span>page1.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;Page2.qml&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buttonPage1.<span class="me1">z</span><span class="sy0">=-</span><span class="nu0">1</span> <span class="co1">//Hide button</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Page2.qml</em> – second wizard page</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>page2Container</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">200</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">80</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">80</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;yellow&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Loader<span class="br0">&#123;</span>id<span class="sy0">:</span>page2<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text<span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span><span class="st0">&quot;Second page loaded&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Button<span class="br0">&#123;</span>id<span class="sy0">:</span>buttonPage2</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">bottom</span><span class="sy0">:</span>page2Container.<span class="me1">bottom</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">right</span><span class="sy0">:</span> page2Container.<span class="me1">right</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span>page2.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;Page3.qml&quot;</span><span class="sy0">;</span>buttonPage2.<span class="me1">z</span><span class="sy0">=-</span><span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Page3.qml</em> – last wizard page</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">120</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">100</span><span class="sy0">;</span>y<span class="sy0">:</span><span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;green&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span><span class="st0">&quot;Last Loaded Page&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>The above wizard implementation is very simple, but suffers of some drawbacks:<br />
• When a new page is loaded the previously loaded page stays unnecessary into memory. <br />
• We use similar loaders for each page – their IDs are different only.<br />
• The order of pages loading is fixed one – the source property values are set in advance.<br />
• There is no mechanism for exchange of information between the caller and the called page and vise-verse. </p>

	<a name="d7fbb3c1ae6af2b913f8f29252ad7eee"></a>	<h3>More Complex Navigation </h3>

	<p>Now we will try to release the restrictions of the loading scheme from the previous section. Firstly, following the Simon Judge <a href="http://www.mobilephonedevelopment.com/qt-qml-tips/">idea</a> <em>[mobilephonedevelopment.com]</em>, we will apply a common <em>Loader</em> for all pages. Secondly, we suppose that the next page to be loaded is not known in advance – it is determined after a condition is evaluated. And finally, we will use signals to pass information between pages and demonstrate how multi-window screens could be constructed.</p>

	<p>A common approach to trigger some actions after an event is fired is to define an own signal like that (for more information <a href="http://doc.qt.nokia.com/4.7/qmlevents.html">here</a> <em>[doc.qt.nokia.com]</em>):</p>

                                             <em>signal MySignal(string message, int trigger)</em>

	<p>where <em>signal</em> is <span class="caps">QML</span> keyword, <em>MySignal</em> is the name of newly defined signal, <em>message</em> is a parameter of type <em>string</em> and <em>trigger</em> is another parameter. The parameters could be of different <span class="caps">QML</span> types. For our purposes we want to pass a string that is the name of wizard page to be loaded and an index to identify the application state.</p>

	<p>The main idea is as follows: </p>

	<p>• When we want to load a page we emit our own signal.<br />
• This signal is caught by a <em>Loader</em> defined somewhere.<br />
• Our signal has a parameter to which we bound the name of the page to be loaded – as an <span class="caps">URL</span> value.</p>

	<p><strong>Use Case</strong>: We will consider an application that consists of a main page (<em>Page1</em>) and two other pages (<em>Page2</em>, <em>Page3</em>). The pages should be loaded sequentially and construct a wizard this way. Some of pages could be loaded checking for a logical condition creating the wizard branches. </p>

	<p><strong>Objectives</strong>: To demonstrate how a flexible wizard could be implemented based on <span class="caps">QML</span> <em>Loader</em> element. Additionally we may complicate the wizard  constructing some multi-windows screens.</p>

	<p><strong>Design</strong>: Pages are loaded one by one. The application starts loading automatically <em>Page1</em>. To load the next page we should click the left mouse button. For <em>Page1</em> we have two wizard branches depending on a logical value. We introduce a current index for pages (an integer) around which the application logic is build. </p>

	<p><strong>Development</strong>: For each page we define the same own signal:</p>

                                              <em>signal handlerLoader(string name, int index)</em>

	<p>To activate this signal (emit the signal) we have to invoke it as a method in a script block. A <em>MouseArea onClicked</em> script block is used. In invocation the name of the page to be loaded is passed as parameter. Emitted signal is attached (automatically) to the signal handler <em>onHandlerLoader</em>, which in turn is connected to a target <em>pageLoader.item</em>. The connection is carried out by a <span class="caps">QML</span> <em>Connections</em> element in the <span class="caps">QML</span> file <em>flexibleLoader.qml</em>. The target <em>pageLoader.item</em> is in fact the object loaded by the <em>Loader</em> (<em>id:pageLoader</em>) defined in the file <em>flexibleLoader.qml</em>. Note that the target property of the <em>Connections</em> element is of type <em>Object</em>. When <em>Page2</em> is loaded we want a second window (<em>NewWindow.qml</em>) to be loaded into the same screen. This is done by a second <em>Loader</em> (<em>id:window</em>), which is defined in the file <em>flexibleLoader.qml</em>. The decision to load this second window is taken in <em>onHandlerLoader</em> block on the base of returned value of <em>trigger</em> parameter. Note that the <em>Loader</em> destroys previously loaded entities when loading new items.</p>

	<p><strong>Code</strong>: </p>

	<p><em>flexibleLoader.qml</em> – application main file</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span>id<span class="sy0">:</span>top</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span><span class="nu0">300</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span><span class="nu0">200</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; Loader<span class="br0">&#123;</span>id<span class="sy0">:</span>window<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">signal</span> handlerLoader<span class="br0">&#40;</span>string name<span class="sy0">,</span> <span class="kw4">int</span> index<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Loader <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span>pageLoader</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; source<span class="sy0">:</span><span class="st0">&quot;Page1.qml&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Connections <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; target<span class="sy0">:</span>pageLoader.<span class="me1">item</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; onHandlerLoader<span class="sy0">:</span><span class="br0">&#123;</span>pageLoader.<span class="me1">source</span><span class="sy0">=</span>name<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>index<span class="sy0">===</span><span class="nu0">2</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.<span class="me1">source</span><span class="sy0">=</span><span class="st0">&quot;NewWindow.qml&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Page1.qml</em> – page 1</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>test1</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;red&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// switchPage1 value is logically controlled somewhere in the code</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">bool</span> switchPage1<span class="sy0">:</span><span class="kw2">true</span> &nbsp; <span class="co1">// false</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> page1Index<span class="sy0">:</span><span class="nu0">2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">signal</span> handlerLoader<span class="br0">&#40;</span>string name<span class="sy0">,</span> <span class="kw4">int</span> index<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span>parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span><span class="br0">&#123;</span><span class="kw1">if</span> <span class="br0">&#40;</span>switchPage1<span class="sy0">==</span><span class="kw2">true</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handlerLoader<span class="br0">&#40;</span><span class="st0">&quot;Page2.qml&quot;</span><span class="sy0">,</span>page1Index<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">else</span> handlerLoader<span class="br0">&#40;</span><span class="st0">&quot;Help.qml&quot;</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Files <em>Page2.qml</em> and <em>Page3.qml</em> are similar to <em>Page1.qml</em>.</p>

	<p><strong>Download Package</strong>: Necessary files: <em>flexibleLoader.qml</em>, <em>Page1.qml</em>, <em>Page2.qml</em>, <em>Page3.qml</em>, <em>Help.qml</em>, <em>NewWindow.qml</em>. Get them from <a href="https://www.sugarsync.com/pf/D7703167_2142254_697719">here</a> <em>[sugarsync.com]</em>.</p>

	<a name="fa8a15c8458b3a67917235ce87dc7082"></a>	<h3>Loader and Component Together</h3>

	<p><strong>Use Case</strong>: Assume the page we are loading uses an external component (component file) and from this component we want to load a next page. What is new in this use case comparing with the previous one? The call to the <br />
<em>Loader</em> is not located at the top level now. It is nested in a component. When the <em>Loader</em> is defined in the main application the pages are loaded in its context. This requires the <em>Loader source</em> property to be determined at the top level also. To solve this problem we use cascading definitions of properties. Firstly, have a look at a diagram illustrating the use case:</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/complexLoader987.jpg" alt="" /></p>

	<p><strong>Design</strong>: It follows the diagram above. The main file <em>componentLoader.qml</em> loads <em>Page1.qml</em>, which in turn loads <em>Page2.qml</em>. The <em>Page2.qml</em> file instantiates a component – <em>Inserted.qml</em>. From within <em>Inserted.qml</em> the <em>Loader</em> in <em>componentLoader.qml</em> is invoked.</p>

	<p><strong>Development</strong>: The issue here is that the signal  <em>handlerLoader</em> has to be activated at the top level of the file <em>Page2.qml</em>. When instantiating component <em>Inserted</em> we define an alias to the top level <em>id</em>:  <em>property alias next1:pop</em>. The signal is invoked in <em>Inserted.qml</em> through a qualified name &#8211; <em>next1.handlerLoader(&#8220;Page3.qml&#8221;,0)</em>.</p>

	<p><strong>Code</strong>: Main file <em>componentLoader.qml</em> and files <em>Page1.qml</em> and <em>Page3.qml</em> are similar to these ones of the previous section.</p>

	<p><em>Page2.qml</em> – this file instantiates component file <em>Insert.qml</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>pop</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; x<span class="sy0">:</span><span class="nu0">30</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;yellow&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> page2Index<span class="sy0">:</span><span class="nu0">3</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">signal</span> handlerLoader<span class="br0">&#40;</span>string name<span class="sy0">,</span> <span class="kw4">int</span> index<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Inserted<span class="br0">&#123;</span>id<span class="sy0">:</span>comp1</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; property alias next1<span class="sy0">:</span>pop</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; y<span class="sy0">:</span><span class="nu0">20</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>Inserted.qml</em> – this is component file</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">62</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;blue&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> <span class="br0">&#123;</span>next1.<span class="me1">handlerLoader</span><span class="br0">&#40;</span><span class="st0">&quot;Page3.qml&quot;</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><strong>Download Package</strong>: Necessary files: <em>componentLoader.qml</em>, <em>Page1.qml</em>, <em>Page2.qml</em>, <em>Page3.qml</em>, <em>Inserted.qml</em>. Get them from <a href="https://www.sugarsync.com/pf/D7703167_2142254_697719">here</a> <em>[sugarsync.com]</em>. </p>

	<a name="1d69f33c86ae4fbd0923907e79f4f399"></a>	<h3>Loader and Inline Component</h3>

	<p><strong>Use case</strong>: We want to implement an advertising banner composed from images and texts. We have several images combined with explanatory texts and these pairs are displayed cyclically. Additionally a button is needed to be bound to each displayed pair – for example to get more information on advertised topic. Have a look at some screenshots.</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/firstImage557.jpg" alt="" /></p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/forthImage497.jpg" alt="" /></p>

	<p><strong>Objectives</strong>: To demonstrate how a loader and an inline component could be used together. Moreover nested components and <span class="caps">QML</span> <em>Timer</em> element are highlighted. </p>

	<p><strong>Design</strong>: Bellow you have a diagram illustrating what and how <span class="caps">QML</span> elements are employed. </p>

	<p><img onload='imgFitOnLoad(this)'  src="http://hotimg23.fotki.com/a/95_87/211_56/elementsHierarchy975.jpg" alt="" /></p>

	<p><strong>Development</strong>: The cycling is implemented through a <span class="caps">QML</span> <em>Timer</em> element. Each time the <em>Timer</em> generates an <em>onTriggered</em> signal, the <em>sourceComponent</em> property of the <em>Loader</em> (<em>id:test</em>) is changed to load the next pair image-text. Images are arranged in a JavaScript array – defined in JavaScript function <em>act()</em>. The texts are placed in the JavaScript array <em>externalArray</em> – defined in a separate file <em>arrayExt.js</em> – just to show how this approach works. The pairs image-text are modeled with a inline component – <em>id:varText</em> – which is loaded sequentially by the loader. The necessary button is implemented as an external component – file <em>Button.qml</em> – and which is nested in the component <em>varText</em>. The handler, connected to this button, is illustrated with <em>console.log()</em> function output.</p>

	<p><strong>Code</strong>: Each cycle forms a state. The states are indentified via the property <em>loop</em>, which gets <em>int</em> values and is used as arrays current index.</p>

	<p><em>bannerComponent.qml</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">import <span class="st0">&quot;arrayExt.js&quot;</span> as FileExt</div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>topLevel</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; function act<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; var element<span class="sy0">=</span><span class="br0">&#91;</span><span class="st0">&quot;fall1.jpg&quot;</span><span class="sy0">,</span> <span class="st0">&quot;fall2.jpg&quot;</span><span class="sy0">,</span><span class="st0">&quot;fall3.jpg&quot;</span><span class="sy0">,</span><span class="st0">&quot;fall4.jpg&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; currentImage<span class="sy0">=</span> element<span class="br0">&#91;</span>loop<span class="br0">&#93;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; currentText<span class="sy0">=</span>FileExt.<span class="me1">externalArray</span><span class="br0">&#91;</span>loop<span class="br0">&#93;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; test.<span class="me1">sourceComponent</span><span class="sy0">=</span>varText<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>loop<span class="sy0">==</span><span class="nu0">3</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop<span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loop<span class="sy0">=</span>loop<span class="sy0">+</span><span class="nu0">1</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">Loader <span class="br0">&#123;</span>id<span class="sy0">:</span>test</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; anchors.<span class="me1">centerIn</span><span class="sy0">:</span>parent</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">property string currentImage </div></li>
<li class="li1"><div class="de1">property string currentText<span class="sy0">:</span><span class="st0">&quot; &quot;</span> </div></li>
<li class="li1"><div class="de1">property <span class="kw4">int</span> loop<span class="sy0">:</span><span class="nu0">0</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">500</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">300</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; color<span class="sy0">:</span><span class="st0">&quot;#f7e5db&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; gradient<span class="sy0">:</span> Gradient <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; GradientStop <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; position<span class="sy0">:</span> <span class="nu16">0.00</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> <span class="st0">&quot;#ecd3d3&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; GradientStop <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; position<span class="sy0">:</span> <span class="nu16">0.71</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> <span class="st0">&quot;#d2e8e8&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">Component <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;id<span class="sy0">:</span> varText</div></li>
<li class="li2"><div class="de2">&nbsp; Rectangle <span class="br0">&#123;</span>id<span class="sy0">:</span>top</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; color<span class="sy0">:</span>topLevel.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">500</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span><span class="nu0">300</span> &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Image <span class="br0">&#123;</span> id<span class="sy0">:</span>innerImage</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">top</span><span class="sy0">:</span> parent.<span class="me1">top</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">topMargin</span><span class="sy0">:</span><span class="nu0">30</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">horizontalCenter</span><span class="sy0">:</span> parent.<span class="me1">horizontalCenter</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span>parent.<span class="me1">width</span><span class="sy0">/</span><span class="nu0">3</span><span class="sy0">;</span>height<span class="sy0">:</span> parent.<span class="me1">height</span><span class="sy0">/</span><span class="nu0">2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; source<span class="sy0">:</span>currentImage</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text<span class="br0">&#123;</span>id<span class="sy0">:</span>answer</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchors.<span class="me1">top</span><span class="sy0">:</span>innerImage.<span class="me1">bottom</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchors.<span class="me1">topMargin</span><span class="sy0">:</span><span class="nu0">30</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;horizontalAlignment<span class="sy0">:</span> Text.<span class="me1">AlignHCenter</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span>parent.<span class="me1">width</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span>currentText &nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Button <span class="br0">&#123;</span>id<span class="sy0">:</span>bottom</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">top</span><span class="sy0">:</span> answer.<span class="me1">bottom</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">topMargin</span><span class="sy0">:</span><span class="nu0">30</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">right</span><span class="sy0">:</span>top.<span class="me1">right</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">rightMargin</span><span class="sy0">:</span><span class="nu0">10</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span>id<span class="sy0">:</span>place</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onClicked<span class="sy0">:</span><span class="br0">&#123;</span>console.<span class="kw3">log</span><span class="br0">&#40;</span><span class="st0">&quot;State index = &quot;</span><span class="sy0">,</span>loop<span class="br0">&#41;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><span class="co1">//end rectangle top</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span> <span class="co1">//end component</span></div></li>
<li class="li2"><div class="de2">Timer <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; interval<span class="sy0">:</span> <span class="nu0">3000</span><span class="sy0">;</span> running<span class="sy0">:</span> true<span class="sy0">;</span> repeat<span class="sy0">:</span> <span class="kw2">true</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; onTriggered<span class="sy0">:</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; act<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="co1">//end onTriggered</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span> <span class="co1">//end Timer</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span> <span class="co1">//end rectangle container</span></div></li>
</ol></div></p>

	<p><em>Button.qml</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">90</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">20</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; color<span class="sy0">:</span> <span class="st0">&quot;#cbd9f3&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; radius<span class="sy0">:</span><span class="nu0">10</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span>parent.<span class="me1">width</span><span class="sy0">;</span>height<span class="sy0">:</span>parent.<span class="me1">height</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; horizontalAlignment<span class="sy0">:</span> Text.<span class="me1">AlignHCenter</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; verticalAlignment<span class="sy0">:</span> Text.<span class="me1">AlignVCenter</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span><span class="st0">&quot;Click me&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; font.<span class="me1">pointSize</span><span class="sy0">:</span> <span class="nu0">8</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p><em>arrayExt.js</em></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="coMULTI">/* This external JavaScript file contains the text blocks */</span></div></li>
<li class="li1"><div class="de1">var externalArray <span class="sy0">=</span> <span class="br0">&#91;</span><span class="st0">&quot;Fist Image – it is the first element of the JavaScript array ‘element’&quot;</span><span class="sy0">,</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;Second Image – its index in the array is 1&quot;</span><span class="sy0">,</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;Third Image - &nbsp;its index in the array is 2&quot;</span><span class="sy0">,</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;Fourth Image - its index in the array is 3&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p><strong>Download Package</strong>: Necessary files: <em>bannerComponent.qml</em>, <em>Button.qml</em>, <em>arrayExt.js</em>, <em>fall1.jpg</em>, <em>fall2.jpg</em>, <em>fall3.jpg</em>, <em>fall4.jpg</em>. Get them from <a href="https://www.sugarsync.com/pf/D7703167_2142254_697719">here</a> <em>[sugarsync.com]</em>. </p>

	<p>Note: The download package is organized in subdirectories corresponding to respective sections: <br />
• Component Element Definition &#8211; Component<br />
• Loader Element Definition – Loader<br />
• Component Element vs. Loader Element – ComponentvsLoader<br />
• Simple Wizard Template &#8211; SimpleWizard<br />
• More Complex Navigation &#8211; ComplexNavigation<br />
• Loader and Component Together &#8211; LoaderandComponent<br />
• Loader and Inline Component &#8211; LoaderInline</p>

	<p><a href="https://www.sugarsync.com/pf/D7703167_2142254_697719">Download Package</a> <em>[sugarsync.com]</em>.</p>]]></description>
      <dc:subject>QML Application Structuring Approaches</dc:subject>
      <dc:date>2012-02-17T07:37:12+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools &#45;&gt; Squish</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools::Squish</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools::Squish</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish_Hungarian">Magyar</a> <a href="http://developer.qt.nokia.com/wiki/Category:Tools::SquishSpanish">Español</a></p>

	<a name="b91aea94866669b5d98d816c61b3fcb8"></a>	<h1>Squish</h1>

	<p>Squish is a tool developed by <a href="http://www.froglogic.com/">Froglogic</a> <em>[froglogic.com]</em> used for automatic testing of Qt applications.</p>

	<a name="af68aec6a9ff864bb2ea1a13ec1ac66f"></a>	<h2>Guidelines</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::RecommendedWayOfWorking">The recommended way of working with Squish</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Working_with_long_test_cases">Working with long test cases</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Load-testing">Load testing</a></li>
	</ul>

	<a name="28ca8b5b1bf803c981127800d9f7baf2"></a>	<h2>Tips and Tricks</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Verifying_the_value_of_a_QLabel">Verifying the value of a QLabel</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Verifying_the_existence_of_a_menu_item">Verifying the existence of a menu item</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Finding_list_items_that_ends_in_a_given_string">Finding list items that ends in a given string</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Robust_selection_of_listview_or_treeview_items_with_variable_text">Robust selection of items in a tree or list view with variable text</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Iterating_through_a_table">Iterating through a table</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Custom_settings_for_test_runs">Custom settings for test runs</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Waiting_for_input_from_the_test_operator">Waiting for input from the test operator</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Hooking_into_slow-launching_subprocesses_on_Windows">Hooking into slow launching subprocesses on Windows</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Waiting_for_a_progress_bar_or_progress_dialog">Waiting for a progress bar or progress dialog</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Navigating_a_QDateEdit">Navigating a QDateEdit</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Using_Squish_and_custom_properties">Using Squish and custom properties</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Generating-test-data">Generating test data</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Calculating-checksums">Calculating checksums</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Clicking-link-in-label">Clicking link in label</a></li>
	</ul>

	<a name="cf270e40d273f9e7fd7c3061729060c3"></a>	<h2>Training</h2>

	<p>Need help or <a href="http://www.kdab.com/index.php?option=com_content&amp;view=article&amp;id=119:testing-qt-applications-with-froglogics-squish&amp;catid=49:course-content&amp;Itemid=119">training</a> <em>[kdab.com]</em> with Squish: feel free to contact <a href="mailto:info@kdab.com"><span class="caps">KDAB</span></a>.</p>

	<a name="d9628cd29eefb13a9e064f50a87ef236"></a>	<h2>Similar tools</h2>

	<ul>
		<li><a href="https://projects.forum.nokia.com/Testabilitydriver">Testability Driver</a> <em>[projects.forum.nokia.com]</em> &#8211; A generic driver which provides access to Qt software for test automation harnesses.</li>
	</ul>]]></description>
      <dc:subject>Category:Tools &#45;&gt; Squish</dc:subject>
      <dc:date>2012-02-16T08:42:28+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools &#45;&gt; Squish &#45;&gt; Clicking link in label</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Clicking&#45;link&#45;in&#45;label</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools::Squish::Clicking&#45;link&#45;in&#45;label</guid>
      <description><![CDATA[<a name="494828fb3ed70a5d4b8082a2e7812525"></a>	<h1>Clicking link in label</h1>

	<p>As is commonly known, you can put in hyper text links in a regular QLabel in Qt, by using simple <span class="caps">HTML</span> syntax. Then of course, you want to be able to click this link in your Squish tests. However, Squish does not have a clickLink() function, as it does for e.g. clickButton() or clickTab(), so what happens during recording is that you will get code similar to:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">mouseClick<span class="br0">&#40;</span>waitForObject<span class="br0">&#40;</span><span class="st0">&quot;:MyQLabel&quot;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="nu0">31</span><span class="sy0">,</span> <span class="nu0">14</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">LeftButton</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>That is, hard coded coordinates for where the link is. So if the position of the link would change for whatever reason (different platform, new text added, different font) the test will break.</p>

	<p>In Squish 4.1, a new function named installSignalHandler() was added. This lets your test script react to signals emitted from the application code. We can use this function combined with the fact that a signal is emitted from a QLabel whenever a link is hovered. This will let us implement a function for clicking arbitrary links in a label.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">_lookingFor <span class="sy0">=</span> None</div></li>
<li class="li1"><div class="de1">_found <span class="sy0">=</span> False</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">def handleLinkHovered<span class="br0">&#40;</span>obj<span class="sy0">,</span> link<span class="br0">&#41;</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; global _found</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> link <span class="sy0">==</span> _lookingFor<span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; _found <span class="sy0">=</span> True</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">def findLink<span class="br0">&#40;</span>objectName<span class="sy0">,</span> link<span class="br0">&#41;</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; global _lookingFor</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; global _found</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; _lookingFor <span class="sy0">=</span> link</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; _found <span class="sy0">=</span> False</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; object <span class="sy0">=</span> waitForObject<span class="br0">&#40;</span>objectName<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; installSignalHandler<span class="br0">&#40;</span>object<span class="sy0">,</span> <span class="st0">&quot;linkHovered(QString)&quot;</span><span class="sy0">,</span> <span class="st0">&quot;handleLinkHovered&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width <span class="sy0">=</span> object.<span class="me1">width</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; height <span class="sy0">=</span> object.<span class="me1">height</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; y <span class="sy0">=</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">while</span> y <span class="sy0">&lt;</span> height<span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; x <span class="sy0">=</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> x <span class="sy0">&lt;</span> width<span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendEvent<span class="br0">&#40;</span><span class="st0">&quot;QMouseEvent&quot;</span><span class="sy0">,</span> waitForObject<span class="br0">&#40;</span><span class="st0">&quot;:MyQLabel&quot;</span><span class="br0">&#41;</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/QEvent.html"><span class="kw5">QEvent</span></a>.<span class="me1">MouseMove</span><span class="sy0">,</span> x<span class="sy0">,</span> y<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">NoButton</span><span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> _found<span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span>x<span class="sy0">,</span>y<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x <span class="sy0">+=</span> <span class="nu0">5</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; y <span class="sy0">+=</span> <span class="nu0">10</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,-</span><span class="nu0">1</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">def clickLink<span class="br0">&#40;</span>objectName<span class="sy0">,</span> link<span class="br0">&#41;</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#40;</span>x<span class="sy0">,</span> y<span class="br0">&#41;</span> <span class="sy0">=</span> findLink<span class="br0">&#40;</span>objectName<span class="sy0">,</span> link<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw1">if</span> x <span class="sy0">!=</span> <span class="sy0">-</span><span class="nu0">1</span> and y <span class="sy0">!=</span> <span class="nu0">1</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; mouseClick<span class="br0">&#40;</span>objectName<span class="sy0">,</span> x<span class="sy0">,</span> y<span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>.<span class="me1">LeftButton</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>Usage is simply:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">clickLink<span class="br0">&#40;</span><span class="st0">&quot;:MyQLabel&quot;</span><span class="sy0">,</span> <span class="st0">&quot;some-action&quot;</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>What the code does is to install a signal handler for the linkHovered(QString) signal as mentioned above, then moving the mouse cursor over the QLabel until the signal is emitted and the link hovered is the one we are looking for. If the link is not found, nothing is clicked.</p>]]></description>
      <dc:subject>Category:Tools &#45;&gt; Squish &#45;&gt; Clicking link in label</dc:subject>
      <dc:date>2012-02-16T08:42:16+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools &#45;&gt; QDoc</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools::QDoc</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools::QDoc</guid>
      <description><![CDATA[<a name="006a219b0a281c307e1deaa27dba4ac0"></a>	<h1>QDoc</h1>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h2>Introduction</h2>

	<p>qdoc3 is the currently available configurable documentation generation tool. qdoc3 is used to generate the Qt Reference Documentation. The <a href="http://doc.qt.nokia.com/qdoc/">QDoc manual</a> <em>[doc.qt.nokia.com]</em> is regularly updated.</p>

	<a name="35bacce0321a2694ee84492624761061"></a>	<h3>Current features</h3>

	<ul>
		<li>Supports C++ and <span class="caps">QML</span> input.</li>
		<li>Supports <span class="caps">HTML</span> and <span class="caps">DITA</span> <span class="caps">XML</span> output.</li>
		<li>Possibility to link multiple documentation packages together using index files.</li>
	</ul>

	<a name="dccd1fc1b7511b0993d6c5601d8cc8f6"></a>	<h2>Future changes</h2>

	<p>It is hard to maintain and implement new features in qdoc3. qdoc3 is currently also not able to generate properly modularized Qt reference documentation. Therefore some work is required to future-proof QDoc. This will probably require a rewrite of significant parts of QDoc.</p>

	<p>Proposed changes are:
	<ul>
		<li>Rename qdoc3 to just qdoc.</li>
		<li>Make it possible to run QDoc on a single file.</li>
		<li>Convert QDoc to an architecture which uses plugins. This would make it possible to ship plugins with their respective modules (ship qdoc-base in qtbase and the <span class="caps">QML</span> parsing plugin in QtDeclarative). It would then also be possible to easily implement plugins for different input/output formats and different.</li>
		<li>Use a proper C++ parser. Currently qdoc3 tries to use some tricks to generate documentation. qdoc3 for instance does not expand macros, which means that a macro has to be added to an ignore list to skip parsing the macro. A solution could be to use the Abstract Syntax Tree-parser which is used by Qt Creator. That parser properly expands macros and would make using ignore lists obsolete.</li>
		<li>Make it possible to run QDoc on individual modules, merging the content afterwards if requested.</li>
		<li>Merge the Generator and PageGenerator classes, these classes were used separately for QtJambi, but now All generators are a subclass of PageGeneratr, which is a subclass of Generator.</li>
	</ul></p>

	<a name="f2474d45bd57f6f230f136456dc5c447"></a>	<h2>Requested Features</h2>

	<p>See also development@qt-project.org, <span class="caps">RFC</span>: The Future of QDoc</p>

	<ul>
		<li>Make it possible to have documentation in headers</li>
		<li>Enums should be documented in the header inline (doxygen style)</li>
		<li>Have Qt Creator be able to build the docs as target</li>
	</ul>]]></description>
      <dc:subject>Category:Tools &#45;&gt; QDoc</dc:subject>
      <dc:date>2012-02-15T22:58:26+00:00</dc:date>
    </item>

    <item>
      <title>QtLocales</title>
      <link>http://developer.qt.nokia.com/wiki/QtLocales</link>
      <guid>http://developer.qt.nokia.com/wiki/QtLocales</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/QtLocales_Bulgarian">Български</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#bbc9105ee8508ce6e083a589a351e83a">Basics</a></li>
<li><a href="#b7d015a629ed0732fefdb0ed8e8fd848">QSystemLocale</a></li>
<li><a href="#847f5d8a6a0c3317c631583512f86c61">The default locale</a></li>
<li><a href="#b77d01c457beb23e622cd14f4ae21e3b">QLocale</a></li>
<li><a href="#1186d40c962b370c82f69913480c15e1">Fallback locale</a></li>
<li><a href="#8a9c9bcf25ce7ddc7924a3ae4b5cb65d">Widgets and locales</a></li></ul>
</div>

	<p>Written By : Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="bbc9105ee8508ce6e083a589a351e83a"></a>	<h1>Basics</h1>

	<p>A locale is a set of parameters that define language and other preferences a user may choose for their interface. <a href="http://developer.qt.nokia.com/wiki/BasicsOfLocales">Basics of Locales</a> <em>[developer.qt.nokia.com]</em> explains the basics. In Qt, locales are implemented using QLocale and QSystemLocale.</p>

	<a name="b7d015a629ed0732fefdb0ed8e8fd848"></a>	<h1>QSystemLocale</h1>

	<p>QSystemLocale is an interface to query the user&#8217;s locale information. <a href="http://doc.qt.nokia.com/qsystemlocale.html#query">QSystemLocale::query()</a> <em>[doc.qt.nokia.com]</em> can be used to query the locale data including the name of a month, the negative sign for numbers etc.</p>

	<p>QSystemLocale provides locale information from the Operating System. On Windows, QSystemLocale::query() uses <a href="http://msdn.microsoft.com/en-us/library/dd318101(v=vs.85">GetLocaleInfo</a> <em>[msdn.microsoft.com]</em>).aspx. On the Mac OS X, QSystemLocale::query() uses CFLocaleGetValue. On Linux, query() returns only the measurement system by inspecting the LC_MEASUREMENT, LC_ALL and <span class="caps">LANG</span> environment variables (in that order).</p>

	<p>QSystemLocale::query() can be overridden by an application to provide further customizations to the user&#8217;s locale.</p>

	<a name="847f5d8a6a0c3317c631583512f86c61"></a>	<h1>The default locale</h1>

	<p>Qt programs can be run in any locale by setting the &#8216;default&#8217; locale using QLocale::setDefault(). When the default locale is not set, Qt uses the information from QSystemLocale i.e the locale information from the Operating System.</p>

	<a name="b77d01c457beb23e622cd14f4ae21e3b"></a>	<h1>QLocale</h1>

	<p>QLocale is the &#8220;front-end&#8221; class that helps in formatting data based on a locale id. QLocale uses the &lt;language&gt;_&lt;country&gt;.&lt;codeset&gt; format for the locale identifier. A QLocale that is created using no arguments (QLocale()) is equivalent to the default locale. When the default locale is not set, QLocale() is equivalent to the system locale. </p>

	<p>There are two code paths that QLocale uses to determine the formatting information. The first case is when the default locale (QLocale::setDefault) has not been set and a QLocale object with no constructor arguments is used. In such a case, QLocale() queries all formatting information through QSystemLocale::query(). This results in QLocale formatting data as it has been configured in the Operating System. In the second case, a default locale has been set or a QLocale object is created with a language and country (locale id). In this case, Qt refers to <a href="http://qt.gitorious.org/+qt-developers/qt/releases/blobs/0d00798f6bdd098dbb59c6f1da5be5efd6c283fa/src/corelib/tools/qlocale_data_p.h">qlocale_data_p.h</a> <em>[qt.gitorious.org]</em> to determine how to format data. qlocale_data_p.h is generated from <a href="http://cldr.unicode.org/index/downloads"><span class="caps">CLDR</span></a> <em>[cldr.unicode.org]</em> using the cldr2qlocalexml.py and qlocalexml2cpp.py scripts at <a href="http://qt.gitorious.org/qt/qt/trees/169099b5e9c77c6633deb3c7bb949800a5f80ec2/util/local_database">local_database</a> <em>[qt.gitorious.org]</em>.</p>

	<p>To reiterate:
	<ul>
		<li>When using the system locale, formatting information is queried from the OS and not <span class="caps">CLDR</span> data.</li>
		<li>When a default locale is set or a QLocale object is created with a locale id, formatting information is obtained from <span class="caps">CLDR</span> data.</li>
	</ul></p>

	<a name="1186d40c962b370c82f69913480c15e1"></a>	<h1>Fallback locale</h1>

	<p>The Fallback locale (<a href="http://doc.qt.nokia.com/qsystemlocale.html#fallbackLocale">QSystemLocale::fallbackLocale</a> <em>[doc.qt.nokia.com]</em>) is a QLocale created with the locale id detected using environment variables (LC_ALL and <span class="caps">LANG</span>). If the environment variables are not set, GetUserDefaultLCID is used on Windows and CFLocaleGetIdentifier is used on Mac OS X.</p>

	<a name="8a9c9bcf25ce7ddc7924a3ae4b5cb65d"></a>	<h1>Widgets and locales</h1>

	<p>Every widget can be set a locale individually using QWidget::setLocale(). Locales propagate from parent to children. When not set, it is the same as the default locale. Locale settings propagate to children. Qt sends a QEvent::LocaleChange event to a widget when it&#8217;s locale changes.</p>]]></description>
      <dc:subject>QtLocales</dc:subject>
      <dc:date>2012-02-15T22:56:18+00:00</dc:date>
    </item>

    <item>
      <title>QtLocales_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/QtLocales_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/QtLocales_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/QtLocales">English</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#c2deac0294e92ea9237b726f391d4703">Основи</a></li>
<li><a href="#b7d015a629ed0732fefdb0ed8e8fd848">QSystemLocale</a></li>
<li><a href="#be6a11e23ac87d048584a0543f49ae60">Локализация по подразбиране</a></li>
<li><a href="#b77d01c457beb23e622cd14f4ae21e3b">QLocale</a></li>
<li><a href="#e11ccf5da4a6e6df7a7f14a711198e6e">Резервна локализация</a></li>
<li><a href="#7a264383200f586c562357058bf635cb">Графични елементи и локализации</a></li></ul>
</div>

	<p>Написано от : Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="c2deac0294e92ea9237b726f391d4703"></a>	<h1>Основи</h1>

	<p>Като за начало може да прочетете <a href="http://developer.qt.nokia.com/wiki/BasicsOfLocales">Основи на локализациите</a> <em>[developer.qt.nokia.com]</em> . В Qt, локализациите са реализирани чрез QLocale и QSystemLocale.</p>

	<a name="b7d015a629ed0732fefdb0ed8e8fd848"></a>	<h1>QSystemLocale</h1>

	<p>QSystemLocale е интерфейс за запитване за информация за локализацията на потребителя. <a href="http://doc.qt.nokia.com/qsystemlocale.html#query">QSystemLocale::query()</a> <em>[doc.qt.nokia.com]</em> може да се използва за да се взема информация като име на месеца, отрицателен знак за числа и т.н.</p>

 QSystemLocale предоставя информация за локализацията от операционната система. На Windows, QSystemLocale::query() използва <a href="http://msdn.microsoft.com/en-us/library/dd318101(v=vs.85">GetLocaleInfo</a> <em>[msdn.microsoft.com]</em>).aspx , на Mac OS X &#8211; CFLocaleGetValue, а на Линукс, query() връща само информацията, получена от инспектирането на променливите на средата LC_MEASUREMENT, LC_ALL и <span class="caps">LANG</span> ( в този ред ).

	<p>QSystemLocale::query() може да бъде предефинира от приложението с цел да предостави по-нататъшно персонализиране на потребителската локализация.</p>

	<a name="be6a11e23ac87d048584a0543f49ae60"></a>	<h1>Локализация по подразбиране</h1>

	<p>Qt програмите мога да се пускат с всякаква локализация като се посочи такава по подразбиране с QLocale::setDefault(). Когато не е зададена локализация по подразбиране, Qt използва информацията от QSystemLocale, т.е тази от операционната система.</p>

	<a name="b77d01c457beb23e622cd14f4ae21e3b"></a>	<h1>QLocale</h1>

	<p>QLocale е &#8220;front-end&#8221; клас, който помага във форматирането на данните, базирайки се на идентификатора на локализацията. QLocale използва формата &lt;език&gt;_&lt;страна&gt;.&lt;код&gt; за идентификатор. QLocale, който е създаден без параметри (QLocale()) е еквивалентен на този по подразбиране. Когато няма зададен по подразбиране, се използва системният. </p>

	<p>Има два начина, по които QLocale определя форматирането. Първия начин е, когато няма зададена по подразбиране локализация (QLocale::setDefault) и QLocale обект е създаден с конструктор по подразбиране. В такъв случай, QLocale() събира всичката информация през QSystemLocale::query(). Втория вариант е, когато има зададена по подразбиране локализация или QLocale обект е създаден с език и страна(идентификатор на локализацията). В този случай, Qt се обръща към <a href="http://qt.gitorious.org/+qt-developers/qt/releases/blobs/0d00798f6bdd098dbb59c6f1da5be5efd6c283fa/src/corelib/tools/qlocale_data_p.h">qlocale_data_p.h</a> <em>[qt.gitorious.org]</em> за да определи как да форматира данните. qlocale_data_p.h е генериран от <a href="http://cldr.unicode.org/index/downloads"><span class="caps">CLDR</span></a> <em>[cldr.unicode.org]</em> като се използват скриптовете cldr2qlocalexml.py и qlocalexml2cpp.py от <a href="http://qt.gitorious.org/qt/qt/trees/169099b5e9c77c6633deb3c7bb949800a5f80ec2/util/local_database">local_database</a> <em>[qt.gitorious.org]</em>.</p>

	<p>Нека да повторим:
	<ul>
		<li>Когато използваме системна локализация, информацията за форматирането идва от ОС-а, а не от <span class="caps">CLDR</span> данните.</li>
		<li>Когато има зададена локализация по подразбиране или QLocale обект е създаден с идентификатор, информацията за форматирането идва от <span class="caps">CLDR</span> данните.</li>
	</ul></p>

	<a name="e11ccf5da4a6e6df7a7f14a711198e6e"></a>	<h1>Резервна локализация</h1>

	<p>Резервната локализация (<a href="http://doc.qt.nokia.com/qsystemlocale.html#fallbackLocale">QSystemLocale::fallbackLocale</a> <em>[doc.qt.nokia.com]</em>) е QLocale създаден като се използва идентификатор, намерен в променливите на средата (LC_ALL и <span class="caps">LANG</span>). Ако тези променливи не са настроени, GetUserDefaultLCID се използва на Windows и CFLocaleGetIdentifier на Mac OS X.</p>

	<a name="7a264383200f586c562357058bf635cb"></a>	<h1>Графични елементи и локализации</h1>

	<p>На всеки графичен елемент може да се зададе индивидуална локализация чрез QWidget::setLocale(). Локализацията се предава от родител на децата, когато не е зададена.<br />
Qt изпраща събитието QEvent::LocaleChange към графичен елемент, когато неговата локализация се смени.</p>]]></description>
      <dc:subject>QtLocales_Bulgarian</dc:subject>
      <dc:date>2012-02-14T21:39:30+00:00</dc:date>
    </item>

    <item>
      <title>QtWebKit_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/QtWebKit_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/QtWebKit_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/QtWebKit">English</a> <a href="http://developer.qt.nokia.com/wiki/QtWebKit_Spanish">Spanish</a> </p>

	<a name="24664ec765bdb273c6d4b82b194fccf5"></a>	<h1>QtWebKit</h1>

	<a name="7f4ec8945207d0259f9bcdde37406181"></a>	<h2>Какво е Qt WebKit?</h2>

	<p>WebKit е един от най-популярните начини за обработка и визуализация на уеб страници и изпълнение на JavaScript.<br />
За повече информация посетете <a href="http://en.wikipedia.org/wiki/Webkit">страницата за WebKit в Wikipedia</a> <em>[en.wikipedia.org]</em></p>

	<p>Qt WebKit е порт на WebKit към Qt. QtWebKit ползва публични <span class="caps">API</span> на Qt и теоретично може да бъде ползван на всяка платформа, която се подържа от Qt (теоретично, защото WebKit се нужда е от добър съвременен компилатор ).</p>

	<a name="04cd417790dcb4ede6a4e4edfb713b7c"></a>	<h2>Разработване на QtWebKit</h2>

	<a name="0d1e0cd7fc49966f197e742af2f30e95"></a>	<h3>Начало</h3>

	<p>QtWebKit е модул на Qt. За да го полвате трябва да го включите във вашия проект. Добавете следният ред съм вашия .pro файл:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">QT</span></a> <span class="sy0">+=</span> webkit</div></li>
</ol></div></p>

	<a name="da8f7e4c13f5dc0160d04e714bf83145"></a>	<h3>Приложения, използващи QtWebKit</h3>

	<p>QtWebKit често се ползва за броузъри или за вграждане към други приложения , за да обработва уеб съдържание.</p>

	<a name="b70876a82cde00504e1d71307812770f"></a>	<h2>Как да вземем участие в разработването на QtWebKit?</h2>

	<p>Работата по QtWebKit  е напълно отворена. Всеки, който иска да се присъедини е добре дошъл.</p>

	<a name="ff3452841c922dbb8a1731c9e4601a30"></a>	<h3>Комуникация</h3>

	<p>Име ежедневни дискусии в <span class="caps">IRC</span> или по майлинг листата.</p>

	<p>Каналът в <span class="caps">IRC</span> #qtwebkit се ползва за разработване с Qt, каналът #webkit е за обща разработка на WebKit.</p>

	<p>Основните майлинг листи са <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt" title="WebKit-Qt mailing-list">WebKit-Qt</a> <em>[lists.webkit.org]</em> и <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev" title="WebKit-dev mailing list">WebKit-dev</a> <em>[lists.webkit.org]</em></p>

	<p>Моля, обърнете внимание, че тези методи за комуникация се ползват са самото разработване на <strong>WebKit</strong>, а не за разработване на приложения, които го ползват.</p>]]></description>
      <dc:subject>QtWebKit_Bulgarian</dc:subject>
      <dc:date>2012-02-13T21:30:45+00:00</dc:date>
    </item>

    <item>
      <title>QtWebKit</title>
      <link>http://developer.qt.nokia.com/wiki/QtWebKit</link>
      <guid>http://developer.qt.nokia.com/wiki/QtWebKit</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/QtWebKit_Spanish">Spanish</a> <a href="http://developer.qt.nokia.com/wiki/QtWebKit_Bulgarian">Български</a></p>

	<a name="24664ec765bdb273c6d4b82b194fccf5"></a>	<h1>QtWebKit</h1>

	<a name="3eeba0663ca3a8ad6139fe249a26b711"></a>	<h2>What is Qt WebKit?</h2>

	<p>WebKit is one of the major engine to render webpages and execute JavaScript code.<br />
More information about <a href="http://en.wikipedia.org/wiki/Webkit" title="WebKit on Wikipedia">WebKit on Wikipedia</a> <em>[en.wikipedia.org]</em></p>

	<p>Qt WebKit is the port of WebKit on top of Qt. QtWebKit relies on the public <span class="caps">API</span>s of Qt and can theoretically be used on any platform supported by Qt (theoretically because WebKit also requires a recent/good compiler).</p>

	<a name="d165ae4439db3f040153ad9138b7c3e1"></a>	<h2>Developing with QtWebKit</h2>

	<a name="cb59b87e00d11222bfd9159d0d23836f"></a>	<h3>Getting started</h3>

	<p>QtWebKit is a module of Qt, to use you need to add it to your project file. Add the following line to your .pro file:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">QT</span></a> <span class="sy0">+=</span> webkit</div></li>
</ol></div></p>

	<a name="425a65fffc954f66c5cbe162d9356c1e"></a>	<h3>Applications using QtWebKit</h3>

	<p>QtWebKit is often used as a rendering engine, as a runtime, or to write a browser.</p>

	<a name="f99ce069a20b964b14ae4bfc0f4fdec3"></a>	<h2>How to participate in the development of QtWebKit?</h2>

	<p>The work on QtWebKit is fully open. Everyone interested is welcome to participate.</p>

	<a name="07a3dd247ad6bec7fe401aa11619959f"></a>	<h3>Communication</h3>

	<p>The daily discussions are done on <span class="caps">IRC</span> and on mailing lists. </p>

	<p>On <span class="caps">IRC</span>, the channel #qtwebkit is used for the development with Qt, and the channel #webkit for general development of WebKit, both channels are on the network FreeNode. (For a full list of <span class="caps">IRC</span> channels see  <a href="http://developer.qt.nokia.com/wiki/OnlineCommunities">OnlineCommunities</a>.)</p>

	<p>Mails threads are used for in-depth discussion like new <span class="caps">API</span>s or architectural changes. The main mailing lists to join are <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt" title="WebKit-Qt mailing-list">WebKit-Qt</a> <em>[lists.webkit.org]</em> and <a href="http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev" title="WebKit-dev mailing list">WebKit-dev</a> <em>[lists.webkit.org]</em></p>

	<p>Note that those mailing list and <span class="caps">IRC</span> channel are for the development <strong>of WebKit</strong> itself, not the development of application <strong>using WebKit</strong>.</p>]]></description>
      <dc:subject>QtWebKit</dc:subject>
      <dc:date>2012-02-11T21:28:51+00:00</dc:date>
    </item>

    <item>
      <title>QtVariant</title>
      <link>http://developer.qt.nokia.com/wiki/QtVariant</link>
      <guid>http://developer.qt.nokia.com/wiki/QtVariant</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/QtVariant-SimplifiedChinese">简体中文</a> <a href="http://developer.qt.nokia.com/wiki/QtVariant_Bulgarian">Български</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#fd8814e213873ee71e45b4b67c37116b">QtVariant</a><ul>
<li><a href="#0b79795d3efc95b9976c7c5b933afce2">Introduction</a></li>
<li><a href="#024b9f0f1fb1ab8f9a92b9a8dfbccd7b">QVariant functionality requirements</a></li>
<li><a href="#0813f54291ef7666c6915d7b009ca56a">Storing the value as 'void *'</a></li>
<li><a href="#c29248f4c3a81cb85d28285d96f9da54">Arriving at the solution</a></li></ul>
</li></ul>
</div>

	<a name="fd8814e213873ee71e45b4b67c37116b"></a>	<h1>QtVariant</h1>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h2>Introduction</h2>

	<p>In C++, a variable needs to have its type known at compile time. There are situations that however require us to deal with variables whose type is known only at run time. For example, let&#8217;s say you have a function that returns a value from the database. What would its return value be? In C, it would be a &#8220;void *&#8221; and an additional information would provide its type. Or assume that you allow the user to attach arbitrary information to the cells of your custom table widget. What type be the argument type for this function setUserCellData(type x)?</p>

	<p>A QVariant can be used in the above situations and can be used to hold a value of any type. You can ask a QVariant for its type and handle the value stored inside it appropriately.</p>

	<p>Before understanding Qt&#8217;s implementation, we will first try to see the various problems involved in designing the QVariant to appreciate the final solution better.</p>

	<a name="024b9f0f1fb1ab8f9a92b9a8dfbccd7b"></a>	<h2>QVariant functionality requirements</h2>

	<ol>
		<li>QVariant should not (and cannot) be a template class. If QVariant is a template, every class that store a QVariant needs to become a template.</li>
		<li>QVariant must work for both <span class="caps">POD</span> and non-<span class="caps">POD</span> data types. It should work for any type that is copyable and behaves as a value based type. Note that the support for non-<span class="caps">POD</span> types means that one cannot use a C union to hold all known types since C++ disallows placing non-<span class="caps">POD</span> types in a union.</li>
		<li>QVariant must be able to store custom user types. So, if you write a MyStruct, you should be able to place it in a QVariant.</li>
		<li>QVariant should (and cannot) not use C++ <span class="caps">RTTI</span>. In C++, <span class="caps">RTTI</span> only works with polymorphic classes.</li>
	</ol>

	<a name="0813f54291ef7666c6915d7b009ca56a"></a>	<h2>Storing the value as &#8216;void *&#8217;</h2>

	<p>An idea would be to hold a &#8216;void *&#8217; and a type inside QVariant. We can have a QVariant constructor as a function template that can just fit in any type. Like:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> <a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">union</span> <span class="br0">&#123;</span> </div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="co1">// POD data types</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> i<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">float</span> f<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// All non-POD data types are stored as void *.</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> <span class="sy0">*</span>v<span class="sy0">;</span> </div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span> data<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">enum</span> DataType <span class="br0">&#123;</span> Integer<span class="sy0">,</span> Float<span class="sy0">,</span> NonPod <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// the type of data</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> type<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2"><span class="co1">// Constuctors for built-in/POD data types</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span><span class="kw4">int</span> i<span class="br0">&#41;</span> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; data.<span class="me1">i</span> <span class="sy0">=</span> i<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; type <span class="sy0">=</span> Integer<span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// For all the non-POD types have a template constructor</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">template</span> <span class="sy0">&lt;</span><span class="kw2">typename</span> T<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span><span class="kw4">const</span> T <span class="sy0">&amp;</span>t<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; data.<span class="me1">v</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="kw4">void</span> <span class="sy0">*</span><span class="br0">&#41;</span> <span class="kw1">new</span> T<span class="br0">&#40;</span>t<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; type <span class="sy0">=</span> NonPod<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>However, we will have trouble writing the destructor. How does one &#8216;delete&#8217; the void pointer? In C++ you cannot delete a &#8216;void *&#8217;.</p>

	<a name="c29248f4c3a81cb85d28285d96f9da54"></a>	<h2>Arriving at the solution</h2>

	<p>As we can deduce from above, to delete the void * we simply need to know the type. And since QVariant needs to support user defined types it is not possible to put a huge switch case to reinterpret_cast the void * to a specific type and delete the pointer.</p>

	<p>We also have a problem when trying to access the content of the QVariant. variant.value&lt;MyStruct&gt;() should not crash under any circumstance. If a conversion is not possible, it should return a default constructed MyStruct.</p>

	<p>The solution is to have a system that can construct a value from a void *, destroy a void * and cast a void * type to access the value. If we have functions for these tasks for <em>every</em> type that can be stored in a QVariant, then QVariant can use these functions to work on the void *.</p>

	<p>qMetaTypeConstructHelper and qMetaTypeDeleteHelper are the template construction helpers<br />
qRegisterMetaType&lt;MyStruct&gt;(&#8220;MyStruct&#8221;)
  &#8212;- QMetaType::registerType(&#8220;MyStruct&#8221;, ctr, dtr);
  &#8212;- Internally it&#8217;s all stored in a QVector&lt;QCustomTypeInfo&gt;</p>

	<p>If you do qRegisterMetaType for all types, we are done! But it&#8217;s a pain?<br />
Q_DECLARE_METATYPE(Type)
  &#8212;&#8212; Create a class QMetaTypeId that provides qt_metatype_id() that registers on demand.</p>

  &#8212;- Provides a function 

	<p>qMetaTypeId provides compile time look up of a type&#8217;s id</p>]]></description>
      <dc:subject>QtVariant</dc:subject>
      <dc:date>2012-02-10T20:53:14+00:00</dc:date>
    </item>

    <item>
      <title>QtVariant_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/QtVariant_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/QtVariant_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/QtVariant">English</a> <a href="http://developer.qt.nokia.com/wiki/QtVariant-SimplifiedChinese">简体中文</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#fd8814e213873ee71e45b4b67c37116b">QtVariant</a><ul>
<li><a href="#3a58b45c3f6d4d67082ae9a9ffbc7a0b">Въведение</a></li>
<li><a href="#cdc894b94b1849738d8a098e98e00f07">Изисквания към функционалността на QVariant</a></li>
<li><a href="#c324c6549496882add2114a853dcc2d8">Съхванение на стойността като 'void *'</a></li>
<li><a href="#fdaee954f2e977a7189354194ef6bc93">Намиране на решението</a></li></ul>
</li></ul>
</div>

	<a name="fd8814e213873ee71e45b4b67c37116b"></a>	<h1>QtVariant</h1>

	<a name="3a58b45c3f6d4d67082ae9a9ffbc7a0b"></a>	<h2>Въведение</h2>

	<p>В C++ променливите трябва да имат тип, който да е известен по време на компилацията. Но има ситуации, които налагат да се използват променливи, чийто тип е известен само по време на изпълнение. На пример, нека да кажем, че имате функция, която връща стойност от база данни. Какъв ще бъде типа на върнатата стойност? В C, ще бъде &#8220;void *&#8221; и допълнителна информация ще бъде предоставена за типа и. Или да предположим, че вие позволявате на потребителя да добавя произволна информация в клетките на разработена от вас таблица. Какъв тип трябва да бъде аргумента на тази функция &#8211; setUserCellData(type x)?</p>

	<p>В тези ситуации може да се използва QVariant и той може да съхранява стойност от всеки тип. Вие можете да питате  QVariant за типа и да обработите стойността, съхранена вътре подобаващо.</p>

	<p>Преди да разберем реализацията на Qt, първо ще се опитаме да разберем различните проблеми, включени в дизайна на QVariant, за да оценим по-добре крайното решение.</p>

	<a name="cdc894b94b1849738d8a098e98e00f07"></a>	<h2>Изисквания към функционалността на QVariant</h2>

	<ol>
		<li>QVariant не трябва ( и не може) да бъде шаблонен клас. Ако QVariant е шаблонен, всеки клас, които съхранява QVariant трябва да стане.</li>
		<li>QVariant трябва да работи както за <acronym title="http://en.wikipedia.org/wiki/Plain_Old_Data_Structures"><span class="caps">POD</span></acronym>, така и за не-<span class="caps">POD</span> типове данни. Трябва да работи с всеки тип, който може да се копира и да се държи като клас за съхранение на данни. Забележете, че поддръжката на не-<span class="caps">POD</span> типове, означава, че не може да се използва C типа <em>union</em> за съхранение на всички известни типове данни, тъй като C++ не позволява слагането на не-<span class="caps">POD</span> типове в <em>union</em>.</li>
		<li>QVariant трябва да може да съхранява потребителски типове. Така, че ако напишете MyStruct, трябва да можете да я съхраните в QVariant.</li>
		<li>QVariant не трябва (и не може) да използва C++ <span class="caps">RTTI</span>. В C++, <span class="caps">RTTI</span> работи само с полиморфични класове.</li>
	</ol>

	<a name="c324c6549496882add2114a853dcc2d8"></a>	<h2>Съхванение на стойността като &#8216;void *&#8217;</h2>

	<p>Идейно би било да се пази &#8216;void *&#8217; и типа в QVariant. Може да имаме QVariant конструктор като функционален шаблон, който да пасва на всеки тип. Нещо като:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">class</span> <a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">private</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">union</span> <span class="br0">&#123;</span> </div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="co1">// POD типове данни</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> i<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">float</span> f<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// Всички не-POD типове данни се запазват като void *.</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">void</span> <span class="sy0">*</span>v<span class="sy0">;</span> </div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span> data<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">enum</span> DataType <span class="br0">&#123;</span> Integer<span class="sy0">,</span> Float<span class="sy0">,</span> NonPod <span class="br0">&#125;</span><span class="sy0">;</span> <span class="co1">// типа на данните</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw4">int</span> type<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2"><span class="co1">// Конструктор за вградените/POD типове данни</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span><span class="kw4">int</span> i<span class="br0">&#41;</span> </div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; data.<span class="me1">i</span> <span class="sy0">=</span> i<span class="sy0">;</span> </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; type <span class="sy0">=</span> Integer<span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// За всички не-POD типове имаме шаблонен конструктор</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">template</span> <span class="sy0">&lt;</span><span class="kw2">typename</span> T<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span><span class="kw4">const</span> T <span class="sy0">&amp;</span>t<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; data.<span class="me1">v</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="kw4">void</span> <span class="sy0">*</span><span class="br0">&#41;</span> <span class="kw1">new</span> T<span class="br0">&#40;</span>t<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; type <span class="sy0">=</span> NonPod<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Обаче имаме проблем, когато трябва да направим деструктор. Как да &#8216;delete&#8217; void указател? В C++ не можете да унищожавате &#8216;void *&#8217;.</p>

	<a name="fdaee954f2e977a7189354194ef6bc93"></a>	<h2>Намиране на решението</h2>

	<p>Както можем да се досетим от горния пример, за да унищожим void *, ние просто трябва да знаем типа. И тъй като QVariant трябва да поддържа дефинирани от потребителя типове, не е възможно да се сложи един голям <em>switch</em> с reinterpret_cast на void * към даден тип и да унищожим указателя.</p>

	<p>Също имаме и проблем, когато искаме да вземем съдържанието на QVariant. variant.value&lt;MyStruct&gt;() не трябва да дава грешка при никакви обстоятелства. Ако конвертирането не е възможно, трябва да върнем променлива от тип MyStruct, създадена с конструктора му по подразбиране.</p>

	<p>Решението е да имаме система, която може да конструира стойност от void *, да унищожава void * и да превръща void * в правилния тип, за да може да работи със стойността. Ако имаме функции за тези дейности за <em>всеки</em> тип, който може да се съхранява в QVariant, тогава QVariant може да използва тези функции за да работи с void *.</p>

	<p>qMetaTypeConstructHelper и qMetaTypeDeleteHelper са помощни шаблонни функции<br />
qRegisterMetaType&lt;MyStruct&gt;(&#8220;MyStruct&#8221;)
  &#8212;- QMetaType::registerType(&#8220;MyStruct&#8221;, ctr, dtr);
  &#8212;- Вътрешно всичко се пази в QVector&lt;QCustomTypeInfo&gt;</p>

	<p>Ако направим qRegisterMetaType за всички типове, ще сме готови! Но това не е ли прекалено много работа?<br />
Q_DECLARE_METATYPE(Type)
  &#8212;&#8212; Създава клас QMetaTypeId, който предоставя qt_metatype_id(), което регистрира при нужда.</p>

  &#8212;- Предоставя функция 

	<p>qMetaTypeId предоставя възможност за проверка на номера на типа по време на компилация</p>]]></description>
      <dc:subject>QtVariant_Bulgarian</dc:subject>
      <dc:date>2012-02-10T20:49:39+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools &#45;&gt; QHelpGenerator</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools::QHelpGenerator</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools::QHelpGenerator</guid>
      <description><![CDATA[<a name="882f3caa8fc811bebcab2f149b9902c4"></a>	<h1>Qt Help Generator</h1>

	<p>qhelpgenerator is the tool used to generate help files which can be read by Qt Assistant and Qt Creator.</p>

	<p>qhelpgenerator creates an sqlite database containing the documentation html pages and a list of keywords, which can be used for searching in the documentation.</p>]]></description>
      <dc:subject>Category:Tools &#45;&gt; QHelpGenerator</dc:subject>
      <dc:date>2012-02-09T12:52:38+00:00</dc:date>
    </item>

    <item>
      <title>Category:Tools</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Tools</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Tools</guid>
      <description><![CDATA[<p><strong>English</strong>  <a href="http://developer.qt.nokia.com/wiki/Category:Tools_Russian">Русский</a> <a href="http://developer.qt.nokia.com/wiki/Category:ToolsSpanish">Español</a> <a href="http://developer.qt.nokia.com/wiki/CategoryTools_Italian">Italian</a> <a href="http://developer.qt.nokia.com/wiki/CategoryTools-Hungarian">Magyar</a></p>

	<a name="81fc57fd66cffddf81ca76344db975d8"></a>	<h1>Qt Development Tools </h1>

	<a name="47962f4adef036d44d99f93c1c3205f1"></a>	<h2>Managing Git repositories with Qt Creator</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::GitQtCreator"><strong>Git repository:</strong></a> a great feature of Qt Creator is the integration with different repository management. Among wihich the use of <strong>Git repositories</strong> covers special interest due to the diffusion of open-source portals i.e. gitorious.org, github and the same <a href="http://project.forum.nokia.com">http://project.forum.nokia.com</a> that can host Qt projects using Git.</p>

	<a name="561fed168b748eb438978d51dc589cdd"></a>	<h2>Qt Creator</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtCreator"><strong>Qt Creator</strong></a> is a cross-platform integrated development environment (<span class="caps">IDE</span>) tailored to the needs of Qt developers.</p>

	<a name="6c31255174c556fffb746dd0519bbaa6"></a>	<h2>Project and build management tools</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::qmake"><strong>qmake</strong></a> is a cross-platform build tool that simplifies the build process for development projects across different platforms. qmake automates the generation of Makefiles so that only a few lines of information are needed to create each Makefile.</p>

	<a name="4f41276bb70a687c21a624db6b5a5651"></a>	<h2>Qt Designer</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtDesigner"><strong>Qt Designer</strong></a> is a powerful cross-platform <span class="caps">GUI</span> layout and forms builder for C++ projects. It allows you to rapidly design and build widgets and dialogs using on-screen forms using the same widgets that will be used in your application. Forms created with Qt Designer are fully-functional, and they can be previewed so that you can ensure that they will look and feel exactly as you intended.</p>

	<a name="551bdb98742bbba7e1b14b6aff5f98ef"></a>	<h2>Documentation Tools</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QDoc"><strong>qdoc3</strong></a> is a configurable documentation generation tool, used to generate the Qt Reference Documentation. The <a href="http://doc.qt.nokia.com/qdoc/">QDoc manual</a> <em>[doc.qt.nokia.com]</em> is regularly updated.<br />
<a href="http://developer.qt.nokia.com/wiki/Category:Tools::QHelpGenerator"><strong>qhelpgenerator</strong></a> is the tool used to generate help files which can be read by Qt Assistant and Qt Creator.</p>

	<a name="fb8ac7094506ed3332f2e29a6425f09e"></a>	<h2><span class="caps">HTML</span> Help System</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtAssistant"><strong>Qt Assistant</strong></a> is a configurable and redistributable documentation reader, which can be easily customized and redistributed, thus provides an integrated, context-sensitive help system for your Qt application.</p>

	<a name="53fc0e995e4d6cf69e5713dc4d50836c"></a>	<h2>Internationalization Tools</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtLinguist"><strong>Qt Linguist</strong></a> provides a set of tools that speed the translation and internationalization of applications. Qt supports simultaneous support of multiple languages and writing systems with a single source tree and single application binary.</p>

	<a name="96f5a122f82e2718c90db29f322347ab"></a>	<h2>Qt Simulator</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtSimulator"><strong>Qt Simulator</strong></a> is available as part of the Nokia Qt <span class="caps">SDK</span>, the Qt Simulator is used to test Qt application for mobile devices in an environment similar to that of the target device.</p>

	<a name="5b386a3d97490dbc8792cb248e057957"></a>	<h2>Nokia Analyze Tool (Only for Symbian)</h2>

	<p>Nokia AnalyzeTool provides features that enable the detection of memory leaks and other memory issues in Symbian C++ and Qt software for Symbian devices. The tool is available for use in <span class="caps">SDK</span> emulators or on Symbian devices.</p>

	<p><a href="https://www.forum.nokia.com/info/sw.nokia.com/id/f9d0c7b9-28ce-4e8b-89ff-5004778d7c26/Nokia_AnalyzeTool.html">https://www.forum.nokia.com/info/sw.nokia.com/id/f9d0c7b9-28ce-4e8b-89ff-5004778d7c26/Nokia_AnalyzeTool.html</a></p>

	<a name="474b5ce41d26d76b004eb014c22ac3fe"></a>	<h2>Qt-Complex 1.1.0 Harmattan</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtComplex"><strong>Qt Complex</strong></a> is an open framework for Qt-Quick developers to speed up the UI development. It supports themes, custom graphic elements, development of new objects and more. The <span class="caps">QML</span> components are dynamically loaded instead of being instantiated saving memory and resources. Developers can integrate this framework in new or existing Qt-Quick projects. All the components can be customized and updated by the developer. The user can adopt the Qt-Complex features adding its own elements to the framework. The release <em>1.1.0 Harmattan</em> works on Symbian^1, Symbian^2 and Harmattan Meego 1.2 devices.</p>

	<a name="cab091311b5fc0553cf6062b2e5bc5c8"></a>	<h2>Third-party Tools</h2>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::mingw"><strong>mingw</strong></a> is a free gcc compiler for Windows. It is distributed with Qt Creator for windows and is used to build Qt applications from C++ code.</p>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::Squish"><strong>Squish</strong></a> is a tool developed by Froglogic used for automatic testing of Qt applications.</p>

	<p><a href="http://developer.qt.nokia.com/wiki/Category:Tools::GCF"><strong>Generic Component Framework</strong></a> is a framework with which you can compose your application as a collection of components.</p>]]></description>
      <dc:subject>Category:Tools</dc:subject>
      <dc:date>2012-02-09T12:49:01+00:00</dc:date>
    </item>

    <item>
      <title>index</title>
      <link>http://developer.qt.nokia.com/wiki</link>
      <guid>http://developer.qt.nokia.com/wiki</guid>
      <description><![CDATA[<p><strong>English</strong> 
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_German">Deutsch</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Russian">Русском</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Polish">Polski</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Dutch">Nederlands</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Portuguese">Português</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Spanish">Español</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Ukrainian">Українською</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Persian">فارسی</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Arabic">عربي</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Korean">한국어</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Finnish">Suomi</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki-Home-Catalan">Català</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki-Home-Italian">Italiano</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Japanese">日本語</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_French">Français</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki-Home-Hungarian">Magyar</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Kannada">ಕನ್ನಡ</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Hindi">हिन्दी</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Thai">ภาษาไทย</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_SimplifiedChinese">简体中文</a>
| <a href="http://developer.qt.nokia.com/wiki/Wiki_Home_Bulgarian">Български</a></p>

	<a name="af1b98adf7f686b84cd0b443e022b7a0"></a>	<h1>Categories</h1>

	<a name="6538a23d21c0fbc82e10a62eb7b6a0df"></a>	<h2>Learning (<a href="http://developer.qt.nokia.com/wiki/Category:Learning">Overview</a>)</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:HowTo">&#8220;How To&#8221; collection</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Snippets">Snippets of code</a></li>
		<li><a href="http://developer.qt.nokia.com/faq"><span class="caps">FAQ</span></a> <em>[developer.qt.nokia.com]</em></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Learning::Whitepapers">Whitepapers</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Learning::Demos_and_Examples">Demos and Examples</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Learning::LinksAndMaterial">Links and Material</a></li>
	</ul>

	<a name="8980f3aba05c0ccc73682fddceecc238"></a>	<h2>Developing with Qt (<a href="http://developer.qt.nokia.com/wiki/Category:Developing_with_Qt">Overview</a>)</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_with_Qt::Qt_Quick">Qt Quick</a>: Allowing developers and UI designers to work together to create animated, touch-enabled UIs and applications.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_with_Qt::QtMobility">Qt Mobility</a>: Enabling Qt developers to include standard mobile functionality in their applications.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_with_Qt::Games">Game Development</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_with_Qt::QtWebKit">Qt WebKit</a>: WebKit is an open source web browser engine for displaying <span class="caps">HTML</span> content.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Qt_Supported_Platforms">Qt Supported Platforms</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Bugs">Reporting bugs</a></li>
	</ul>

	<a name="89b4ec0f5d76292f5e153e1aebb7f2e2"></a>	<h2>Developing Qt (<a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt">Overview</a>)</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Bugs">Bugs</a>: Known Bugs and approaches to fix them</li>
		<li><a href="http://wiki.qt-project.org">Qt Project Guidelines</a> <em>[wiki.qt-project.org]</em> Guides and useful information for code contributors to the Qt Project</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Guidelines">Guidelines</a>: General guidelines regarding Qt code (excl. those specifically for code contributions to the Qt Project)</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Instructions">Instructions</a>: Instructions for set-up and tools</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Documentation">Documentation</a>: Resources regarding writing documentation and examples</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Network">Network</a>: The Qt Network module</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Qt_Script">Qt Script</a>: The Qt Script Module</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Lighthouse">Lighthouse</a>: Qt Platform Abstraction</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Qt_Planning">Qt Planning</a>: Qt Public Roadmap Process, Qt Public Roadmap</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Developing_Qt::Qt_5">Qt 5</a>: Proposals, Ideas, Contributors&#8217; Summits Results</li>
	</ul>

	<a name="29a74d71395cf2032bfed5dff7a39312"></a>	<h2>Tools and Add-ons (<a href="http://developer.qt.nokia.com/wiki/Category:Tools">Overview</a>)</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::QtCreator">Qt Creator</a>: A cross-platform <span class="caps">IDE</span> (Integrated Development Environment) tailored to the needs of Qt developers.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Qt_Simulator">Qt Simulator</a>: A fast and lightweight simulator for Qt applications running on Nokia devices.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/QtVSAddin">Qt Visual Studio Add in</a>: Tools for developing Qt application in Visual Studio.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::qmake">qmake</a>: A build system for Qt projects to generate Makefiles.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools::GitQtCreator">Git with QtCreator</a>: Managing Qt projects with the Git repository system.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Tools">Development Tools, Overview</a></li>
	</ul>

	<ul>
		<li>The add-ons are summarized on the <a href="http://developer.qt.nokia.com/wiki/Category:Add-ons">category page</a>.</li>
	</ul>

	<a name="854c60b374ec5e39ed5d641f9d2d28ef"></a>	<h2>Language Bindings (<a href="http://developer.qt.nokia.com/wiki/Category:LanguageBindings">Overview</a>)</h2>

	<ul>
		<li>The language bindings are summarized on the <a href="http://developer.qt.nokia.com/wiki/Category:LanguageBindings">language bindings page</a>.</li>
	</ul>

	<a name="6fd9bd4696dcd4396a0ff2f512ae565b"></a>	<h2>Community (<a href="http://developer.qt.nokia.com/wiki/Category:Community">Overview</a>)</h2>

	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/OnlineCommunities">List of independent Qt community sites and <span class="caps">IRC</span> channels</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Community::Sponsorship">Sponsorship</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Category:Community::Candidates">List of projects applying for sponsorship</a></li>
	</ul>

	<a name="6ce2d3c8c549ab0fd691398bb443efb2"></a>	<h2><span class="caps">API</span> Documentation</h2>

	<ul>
		<li><strong>Qt</strong>: <a href="http://developer.qt.nokia.com/doc/qt-4.8/">4.8</a> <em>[developer.qt.nokia.com]</em>, <a href="http://developer.qt.nokia.com/doc/qt-4.7/">4.7</a> <em>[developer.qt.nokia.com]</em>, <a href="http://doc.qt.nokia.com/4.6/index.html">4.6</a> <em>[doc.qt.nokia.com]</em></li>
		<li><strong>Qt Mobility</strong>: <a href="http://doc.qt.nokia.com/qtmobility-1.2/">1.2</a> <em>[doc.qt.nokia.com]</em>, <a href="http://doc.qt.nokia.com/qtmobility-1.1.0/">1.1</a> <em>[doc.qt.nokia.com]</em>, <a href="http://doc.qt.nokia.com/qtmobility-1.0/">1.0</a> <em>[doc.qt.nokia.com]</em></li>
		<li><strong>Qt Quick Components for Symbian</strong>: <a href="http://doc.qt.nokia.com/qtquick-components-symbian-1.1/">1.1</a> <em>[doc.qt.nokia.com]</em>, <a href="http://doc.qt.nokia.com/qtquick-components-symbian-1.0/">1.0</a> <em>[doc.qt.nokia.com]</em></li>
		<li><strong>Qt Maemo 5</strong>: <a href="http://doc.qt.nokia.com/qt-maemo-4.7/qtmaemo5.html">4.7</a> <em>[doc.qt.nokia.com]</em>, <a href="http://doc.qt.nokia.com/qt-maemo-4.6/qtmaemo5.html">4.6</a> <em>[doc.qt.nokia.com]</em> (only on Maemo 5)</li>
	</ul>

	<a name="205c61d96cfaef8b6624597c44ec06ce"></a>	<h2>General (<a href="http://developer.qt.nokia.com/wiki/Category:General">Overview</a>)</h2>

	<p>There is also a <a href="http://developer.qt.nokia.com/wiki/Special%3ATitles">complete listing of all pages.</a></p>

	<a name="0f68b904e33d9ac04605aecc958bcf52"></a>	<h1>Additional information</h1>

	<p>Every user can create categories but only <a href="http://developer.qt.nokia.com/wiki/Admins">admins</a> can edit and remove them. <a href="http://developer.qt.nokia.com/forums/viewthread/2115">Post your requests in the forum</a> <em>[developer.qt.nokia.com]</em></p>

	<p>Project code should not be displayed on the wiki but instead hosted at a project hosting service of your choice. We recommend <a href="http://qt.gitorious.org/">Gitorious.org</a> <em>[qt.gitorious.org]</em> which is where all of our code goes.</p>

	<p>If you are looking for formatting help and guidelines check the <a href="http://developer.qt.nokia.com/wiki/WikiHelp">Wiki Help</a>.</p>]]></description>
      <dc:subject>index</dc:subject>
      <dc:date>2012-02-09T10:24:21+00:00</dc:date>
    </item>

    <item>
      <title>QtResources</title>
      <link>http://developer.qt.nokia.com/wiki/QtResources</link>
      <guid>http://developer.qt.nokia.com/wiki/QtResources</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/QtResources-SimplifiedChinese">简体中文</a> <a href="http://developer.qt.nokia.com/wiki/QtResources_Bulgarian">Български</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#3b878279a04dc47d60932cb294d96259">Overview</a></li>
<li><a href="#9ffdb95250e26c7a6b468126ac7c75b0">How it works</a></li>
<li><a href="#de7bdb74ed1ae35acb8db45280ac83d3">Q_INIT_RESOURCE</a></li>
<li><a href="#cea2c77dd7562d402e69c4be9cbe1c32">Accessing resources</a></li>
<li><a href="#ed8f6fd8ce6ddd57be4562b8e62db820">Namespacing resources</a></li></ul>
</div>

	<p>Written By : Girish Ramakrishnan, ForwardBias Technologies</p>

	<a name="3b878279a04dc47d60932cb294d96259"></a>	<h1>Overview</h1>

	<p>Qt Resources provide a platform-independent mechanism for embedding arbitrary binary data, including images and sounds, as part of an application executable. See <a href="http://doc.qt.nokia.com/snapshot/resources.html">Documentation</a> <em>[doc.qt.nokia.com]</em> for more details.  </p>

	<p>Implementation-wise, Qt resources have nothing to do with <a href="http://msdn.microsoft.com/en-us/library/ms648007.aspx"><span class="caps">RES</span> files</a> <em>[msdn.microsoft.com]</em> on Windows or <a href="http://en.wikipedia.org/wiki/Resource_fork">resource forks</a> <em>[en.wikipedia.org]</em> on Mac OS X.</p>

	<a name="9ffdb95250e26c7a6b468126ac7c75b0"></a>	<h1>How it works</h1>

	<p>Resource files (i.e .qrc files) are <span class="caps">XML</span> files that specify the files that should be packaged into the final binary. The <em>rcc</em> resource compiler parses the <span class="caps">XML</span> and generates C/C++ code. This generated code contains a C struct that contains the raw bytes of the files listed in the .qrc. These C-structs are then collated in another C-struct to form a tree-like structure as files can be arranged in hierarchies. The details of the C-struct itself is not very interesting, so it&#8217;s not discussed here. With the -_compressed_ option to rcc, the data in the structs are compressed using zlib (by default, compression is off).</p>

	<p>The C-structs need to be registered with Qt for Qt to know about them. The trick is that at the end of every rcc-generated C++ file, rcc places a call to qRegisterResourceData() which registers the C struct with the Qt resource system. By using the <em>constructor function pattern</em>, the qRegisterResourceData() gets invoked before main(). The <em>constructor function pattern</em> is the usage of a global static variable that initializes itself by calling a function.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#ifndef Q_CONSTRUCTOR_FUNCTION</span></div></li>
<li class="li1"><div class="de1"><span class="co2"># define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \</span></div></li>
<li class="li1"><div class="de1"><span class="co2">&nbsp; &nbsp;static const int AFUNC ## __init_variable__ = AFUNC();</span></div></li>
<li class="li1"><div class="de1"><span class="co2"># define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)</span></div></li>
<li class="li2"><div class="de2"><span class="co2">#endif</span></div></li>
</ol></div></p>

	<p>The tail end of a rcc generated C++ file contains something like:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw4">int</span> qInitResources_images<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; qRegisterResourceData<span class="br0">&#40;</span><span class="nu12">0x01</span><span class="sy0">,</span> qt_resource_struct<span class="sy0">,</span> qt_resource_name<span class="sy0">,</span> qt_resource_data<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">1</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Q_CONSTRUCTOR_FUNCTION<span class="br0">&#40;</span>qInitResources_images<span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>Since static variables are initialized before main() is called, all resources are automatically registered before the actual program starts.</p>

	<a name="de7bdb74ed1ae35acb8db45280ac83d3"></a>	<h1>Q_INIT_RESOURCE</h1>

	<p>The constructor function trick works only if the generated C++ file is compiled and linked to the main application directly. If the resources are used in a static library and the library is then linked to the main application, the constructor function will never get called. This is the by nature of C/C++ linking &#8211; functions and variables in libraries that are unused/uncalled from the final program are removed from the final binary (optimized out). If the resources are in a shared library, then the constructor function does get invoked. However, most platforms load shared libraries on demand and the constructor function gets called only when the shared library gets loaded. The consequence is that any resources in plugins used by the main program will not be found by Qt until the plugin itself gets loaded &#8211; it&#8217;s not a problem if the resources in the shared library are used only in the shared library. Note that accessing the resource inside a shared object in the main application does not trigger loading of the shared object since no symbol is exported by <span class="caps">QRC</span> system to trigger loading of the shared object.</p>

	<p>A solution to the above problems is to use the generated variable (the <span class="caps">AFUNC</span> ## <i>init_variable</i> above) or call the generated qInitResource_images() above. The Q_INIT_RESOURCE macro exists for this purpose and is <em>required when you have resources in a static or shared library</em>.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#define Q_INIT_RESOURCE_EXTERN(name) \</span></div></li>
<li class="li1"><div class="de1"><span class="co2">&nbsp; &nbsp; extern int qInitResources_ ## name();</span></div></li>
</ol></div></p>

	<p>The above macro is usually placed in the beginning of main() for every qrc file.</p>

	<a name="cea2c77dd7562d402e69c4be9cbe1c32"></a>	<h1>Accessing resources</h1>

	<p>QFile, QDir, QPixmap etc can all access qrc files. All file access in Qt goes through <a href="http://doc.trolltech.com/4.6/qabstractfileengine.html">QAbstractFileEngine</a> <em>[doc.trolltech.com]</em>. QResource registers a QAbstractFileSystemEngine derivative on startup that provides a valid file system engine (through QAbstractFileEngine::create) when a file name has the &#8220;:&#8221; prefix.</p>

	<a name="ed8f6fd8ce6ddd57be4562b8e62db820"></a>	<h1>Namespacing resources</h1>

	<p>When using resources in plugins, resource paths must be namespaced. Using the plugin name for namespacing resource names is a good technique. For example, <emcite="/plugin_name/resourcenam">e</em>. If an existing resource file path is registered with different data, it is ignored and the first one is preserved.</p>]]></description>
      <dc:subject>QtResources</dc:subject>
      <dc:date>2012-02-09T08:20:34+00:00</dc:date>
    </item>

    <item>
      <title>WikiSyntax</title>
      <link>http://developer.qt.nokia.com/wiki/WikiSyntax</link>
      <guid>http://developer.qt.nokia.com/wiki/WikiSyntax</guid>
      <description><![CDATA[<p><div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#c80abcf137834e031c5b3259fbceaeb8">Wiki Syntax Help</a><ul>
<li><a href="#5796e420c90f94ab40e1d40e4590e500">Linking Pages</a></li>
<li><a href="#2fc110cfb091ef28ff6904c0a1b96266">Linking to Qt Documentation</a></li>
<li><a href="#6be3271a268d25729eb7b8f0556f8bf8">Using Tables</a></li>
<li><a href="#af1b98adf7f686b84cd0b443e022b7a0">Categories</a></li>
<li><a href="#40da7e2e3b586f5e3e5f3d660da4b730">Add a Table of Contents</a></li>
<li><a href="#b982b4a91a012477f20324b3ea0934e4">Right aligned articles</a></li>
<li><a href="#097ec13bec895a4fbfefffc134eae43c">Character Codes, or How to Bypass the Wiki Formatter</a></li>
<li><a href="#d146b869ea17b593c36b0643f098bcae">Embedding Youtube Videos</a></li></ul>
</li></ul>
</div> <br />
<strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/WikiSyntax_German">German</a> <a href="http://developer.qt.nokia.com/wiki/WikiSyntax_Italian">Italiano</a> <a href="http://developer.qt.nokia.com/wiki/WikiSyntax-Hungarian">Magyar</a> <a href="http://developer.qt.nokia.com/wiki/WikiSyntax_Spanish">Spanish</a>  <a href="http://developer.qt.nokia.com/wiki/WikiSyntax_SimplifiedChinese">简体中文</a></p>

	<a name="c80abcf137834e031c5b3259fbceaeb8"></a>	<h1>Wiki Syntax Help</h1>

	<p>ExpressionEngine uses a special wiki syntax to perform a set of actions directly on the wiki. The actual formatting is done by <a href="http://developer.qt.nokia.com/wiki/TextileSyntax">Textile</a>. (have a look on the external page too <a href="http://textism.com/tools/textile/index.php">Textism: Tools: Textile</a> <em>[textism.com]</em>)</p>

	<p>This is only a very short introduction. If you want to learn the more advanced textile features, the <a href="http://developer.qt.nokia.com/wiki/TextileSyntax">TextileSyntax</a> wiki page has all the information for you.</p>

	<a name="5796e420c90f94ab40e1d40e4590e500"></a>	<h2>Linking Pages</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span>PageTitle<span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will link to a page with this title. If the page is not there yet you can create it by clicking the link. Please use camel case. This can also be used in the middle of a sentence like <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">This links to my <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;http://developer.qt.nokia.com/wiki/AwesomeNewPage&quot;</span><span class="sy0">&gt;</span>AwesomeNewPage<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span> here.</div></li>
</ol></div></p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span>PageTitle <span class="sy0">|</span> Display Title<span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will create a link with an alternative title displayed as in <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">This links to my <span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;http://developer.qt.nokia.com/wiki/AwesomeNewPage&quot;</span><span class="sy0">&gt;</span>awesome <span class="kw1">new</span> page<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span></div></li>
</ol></div></p>

	<a name="2fc110cfb091ef28ff6904c0a1b96266"></a>	<h2>Linking to Qt Documentation</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span>Doc<span class="sy0">:</span>ClassName<span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will link to the class page documentation of the latest Qt version, and show the class description as a tooltip. Example: <a class='doc-link' href='/doc/QAccessible'>QAccessible</a></p>

	<a name="6be3271a268d25729eb7b8f0556f8bf8"></a>	<h2>Using Tables</h2>

	<p>Readability is enhanced if your markup indicates a title row and if you color the title row green and alternate entry rows with a light gray.<br />
Note the space before the | designating beginning of a cell.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#123;</span>background<span class="sy0">:</span><span class="co2">#009900&#125;. |_. Title 1 |_. Title 2 |</span></div></li>
<li class="li1"><div class="de1"><span class="sy0">|</span> somestuff in clear row<span class="sy0">|</span> more stuff <span class="sy0">|</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span>background<span class="sy0">:</span><span class="co2">#ddd&#125;. | some stuff in gray row | more stuff |</span></div></li>
</ol></div></p>

<table class="infotable line"><tr style="background:#009900;"><th>Title 1 </th><th>Title 2 </th></tr><tr><td> somestuff in clear row</td><td> more stuff </td></tr><tr style="background:#ddd;"><td> some stuff in gray row </td><td> more stuff </td></tr></table>

	<a name="af1b98adf7f686b84cd0b443e022b7a0"></a>	<h2>Categories</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span>Category<span class="sy0">:</span>Foo<span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will create a category with the title &#8220;Foo&#8221; along with an automatically populated <em>Special Page</em> with all pages in this category. If the category already exists it will sort the page into the indicated category.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span>Category<span class="sy0">:</span>Foo<span class="sy0">::</span><span class="me2">Bar</span><span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will create a child category &#8220;Bar&#8221; inside the parent category &#8220;Foo&#8221;.</p>

	<a name="69ca4966b09ab2032ed371348d2f61b6"></a>	<h3>Link to a Category Page</h3>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span><span class="br0">&#91;</span><span class="sy0">:</span>Category<span class="sy0">:</span>Foo<span class="sy0">::</span><span class="me2">Bar</span><span class="br0">&#93;</span><span class="br0">&#93;</span></div></li>
</ol></div> will link to the indicated category (note the colon!) but not create a new one.</p>

	<a name="40da7e2e3b586f5e3e5f3d660da4b730"></a>	<h2>Add a Table of Contents</h2>

	<p>When a page is long, adding a table of contents can help a lot. You can control alignment and depth of the table.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="br0">&#91;</span>toc align_right<span class="sy0">=</span><span class="st0">&quot;yes&quot;</span> depth<span class="sy0">=</span><span class="st0">&quot;2&quot;</span><span class="br0">&#93;</span> </div></li>
</ol></div></p>

	<p>The optimal depth corresponds structure and size of the article. For a short article a toc is absolutely unnecessary.</p>

	<a name="b982b4a91a012477f20324b3ea0934e4"></a>	<h2>Right aligned articles</h2>

	<p>For wiki pages you can add <br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span>right_aligned<span class="br0">&#93;</span> </div></li>
</ol></div></p>

	<p>to the top of the page and it will be all right aligned on save.</p>

	<a name="097ec13bec895a4fbfefffc134eae43c"></a>	<h2>Character Codes, or How to Bypass the Wiki Formatter</h2>

	<p>Sometimes you need a character in your wiki article that the wiki engine thinks is a formatting code. When this happens, replace the character with a code for the character. <a href="http://www.degraeve.com/reference/specialcharacters.php">Here is a good list of such codes</a> <em>[degraeve.com]</em>.</p>

	<p>For example, in Textile the percent symbol (&#37;) indicates a &lt;span&gt; tag in <span class="caps">HTML</span>, but you may need to show a &#37; in a command line example. Use &amp;&#35;37; instead of &#37; in your example:</p>

	<p>Show:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">set QTDIR<span class="sy0">=%</span>DEV<span class="sy0">%</span>\<a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a></div></li>
</ol></div></p>

	<p>By entering:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">set QTDIR<span class="sy0">=&amp;</span><span class="co2">#37;DEV&amp;#37;\Qt</span></div></li>
</ol></div></p>

	<a name="d146b869ea17b593c36b0643f098bcae"></a>	<h2>Embedding Youtube Videos</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="br0">&#91;</span>YouTubeID<span class="sy0">:&lt;</span>id<span class="sy0">&gt;</span><span class="br0">&#93;</span></div></li>
</ol></div></p>]]></description>
      <dc:subject>WikiSyntax</dc:subject>
      <dc:date>2012-02-08T22:32:50+00:00</dc:date>
    </item>

    <item>
      <title>Building_PySide_on_Windows</title>
      <link>http://developer.qt.nokia.com/wiki/Building_PySide_on_Windows</link>
      <guid>http://developer.qt.nokia.com/wiki/Building_PySide_on_Windows</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://qt-devnet.developpez.com/tutoriels/python/pyside/installer/?page=windows#IV">French</a> <em>[qt-devnet.developpez.com]</em></p>

	<a name="3d61bf757e687e9923298084e709cf26"></a>	<h1>Building PySide on Microsoft Windows</h1>

	<a name="ee68e5b99222bbc29a480fcb0d1d6ee2"></a>	<h2>Prerequisites</h2>

	<ul>
		<li><a href="http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express">MS Visual Studio Express 2008</a> <em>[microsoft.com]</em>
	<ul>
		<li><strong>NOTE1</strong>: To build 64 bit packages with Visual Studio Express 2008 please see <a href="http://maliciousattacker.blogspot.com/2008/10/creating-64-bit-applications-with.html">http://maliciousattacker.blogspot.com/2008/10/creating-64-bit-applications-with.html</a></li>
		<li><strong>NOTE2</strong>: Visual Studio Express 2010 is not supported</li>
	</ul></li>
		<li><a href="http://www.cmake.org/cmake/resources/software.html">CMake</a> <em>[cmake.org]</em></li>
		<li><a href="http://code.google.com/p/msysgit/downloads/list">Git</a> <em>[code.google.com]</em></li>
		<li><a href="http://www.python.org/download/">Python 2.6, 2.7 or 3.2</a> <em>[python.org]</em></li>
	</ul>

	<p><strong><span class="caps">NOTE</span></strong>: Be sure that git.exe and cmake.exe are all in your <span class="caps">PATH</span>.</p>

	<a name="c74c1f42f141c011ca6bd8b1114fc3d0"></a>	<h2>Build</h2>

	<ul>
		<li>Open &#8220;Visual Studio Command Prompt&#8221;:
  [Start Menu]-&gt;Programs-&gt;Microsoft Visual C++ 2008 Express Edition-&gt;Visual Studio Tools</li>
	</ul>

	<ul>
		<li>Get build scripts from repository <a href="https://github.com/PySide/packaging/tree/master/setuptools">https://github.com/PySide/packaging/tree/master/setuptools</a>
    and go to folder &#8220;c:\repositories\packaging\setuptools&#8221;.
    The script can automatically download the sources, compile them, and create the installer, all in one step.</li>
	</ul>

	<ul>
		<li>Run the build.py script (it must be run from &#8220;Visual Studio Command Prompt&#8221;):</li>
	</ul>

  To build the latest stable binaries for Python 2.7 and Qt 4.7.3, run the script with parameters:

  <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; c<span class="sy0">:</span>\repositories\packaging\setuptools<span class="sy0">&gt;</span>c<span class="sy0">:</span>\Python27\python.<span class="me1">exe</span> build.<span class="me1">py</span> <span class="sy0">-</span>d <span class="sy0">-</span>q c<span class="sy0">:</span>\<a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>\4.7.3\bin\qmake.<span class="me1">exe</span></div></li>
<li class="li1"><div class="de1">&nbsp; </div></li>
</ol></div>

  To build the latest development binaries:

  <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; c<span class="sy0">:</span>\repositories\packaging\setuptools<span class="sy0">&gt;</span>c<span class="sy0">:</span>\Python27\python.<span class="me1">exe</span> build.<span class="me1">py</span> <span class="sy0">-</span>d <span class="sy0">-</span>m dev <span class="sy0">-</span>q c<span class="sy0">:</span>\<a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a>\4.7.3\bin\qmake.<span class="me1">exe</span></div></li>
<li class="li1"><div class="de1">&nbsp; </div></li>
</ol></div>

  All build.py parameters:
   <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>p <span class="sy0">&lt;</span>package_version<span class="sy0">&gt;</span> Specify package version. <span class="me1">Default</span> is latest stable version <span class="br0">&#40;</span>1.0.4<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>d &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Download latest sources from git repository</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>m <span class="sy0">&lt;</span>pyside_version<span class="sy0">&gt;</span> &nbsp;Specify what version of modules to download from git repository<span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">'dev'</span> <span class="br0">&#40;</span>master tag<span class="br0">&#41;</span> or <span class="st0">'stable'</span> <span class="br0">&#40;</span>1.0.4 tag<span class="br0">&#41;</span>. <span class="me1">Default</span> is <span class="st0">'stable'</span>.</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp;<span class="sy0">-</span>q <span class="sy0">&lt;</span>qmake_path<span class="sy0">&gt;</span> &nbsp; &nbsp; &nbsp;Locate qmake</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>e &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Check the environment</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Specify what module to build</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">-</span>o &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Create a distribution package only <span class="kw2">using</span> existing binaries</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;</div></li>
</ol></div>

	<ul>
		<li>After the successful build, the final binary distribution can be found in sub-folder &#8220;dist&#8221;:
  <div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; c<span class="sy0">:</span>\repositories\packaging\setuptools\dist\PySide<span class="sy0">-</span>1.0.4qt473.<span class="me1">win32</span><span class="sy0">-</span>py2.7.<span class="me1">exe</span></div></li>
<li class="li1"><div class="de1">&nbsp; </div></li>
</ol></div></li>
	</ul>]]></description>
      <dc:subject>Building_PySide_on_Windows</dc:subject>
      <dc:date>2012-02-07T11:07:30+00:00</dc:date>
    </item>

    <item>
      <title>QtCreatorBuildGdb</title>
      <link>http://developer.qt.nokia.com/wiki/QtCreatorBuildGdb</link>
      <guid>http://developer.qt.nokia.com/wiki/QtCreatorBuildGdb</guid>
      <description><![CDATA[]]></description>
      <dc:subject>QtCreatorBuildGdb</dc:subject>
      <dc:date>2012-02-06T15:40:10+00:00</dc:date>
    </item>

    <item>
      <title>UsingQStringEffectively_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/UsingQStringEffectively_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/UsingQStringEffectively_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/UsingQStringEffectively">English</a> <a href="http://developer.qt.nokia.com/wiki/UsingQStringEffectively-SimplifiedChinese">简体中文</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#a89aa04b23a86a105750c1f9371259f9">QLatin1String : Избягване на скрито заделяне на памет в оператора "=="</a></li>
<li><a href="#b9002b57db5e71282b41a6266583f863">QStringRef : Обработка на стрингове без заделяне на памет</a></li>
<li><a href="#97952e1e1c25dcdb43b559cc6ed44a99">QString::reserve и QString::squeeze</a></li>
<li><a href="#f877da7ebfde3a34e33b417caaa4ab71">QStringBuilder : Бързо обединяване на QString-ове</a></li>
<li><a href="#bf1a3e2ac7d68d0f7f27e8ffa22da75c">QStringMatcher : Бързо търсена на стринг в стринг</a></li></ul>
</div>

	<p>Написано от: Girish Ramakrishnan, ForwardBias Technologies</p>

	<p>Тази статия обяснява предназначението на различните класове свързани с <em>QString</em>.</p>

	<a name="a89aa04b23a86a105750c1f9371259f9"></a>	<h1>QLatin1String : Избягване на скрито заделяне на памет в оператора &#8220;==&#8221;</h1>

	<p>Създаването на QString от <em>char</em> масив може да предизвика заделяне на памет. Пример:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>fruit <span class="sy0">==</span> <span class="st0">&quot;apple&quot;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="co1">// вероятно заделяне на памет</span></div></li>
</ol></div></p>

	<p>QString предоставя QString::operator==(const char *) за сравняване със C-стрингове. Както е обяснено в <a href="http://developer.qt.nokia.com/wiki/QtStrings/">QtString</a> <em>[developer.qt.nokia.com]</em>, кодировката на C-стринговете се определя като се използва QTextCodec::setCodecForCStrings(). Когато не е сложено специално кодиране, Qt изпълнява горното сравнение като предоставя специализирана функция, която сравнява Уникод стринга (fruit) и Latin-1 стринга (&#8216;apple&#8217;). Това сравнение е бързо и не изисква заделяне на памет.</p>

	<p>Обаче, когато QTextCodec::setCodecForCString е нагласен, &#8220;apple&#8221; се конвертира в QString като се използва QString::fromAscii(). Това означава, че QString ще задели памет за стринга &#8220;apple&#8221; и ще създаде копие на C масива преди да изпълни сравнението!</p>

	<p>Разработчиците на приложения нагласяват QTextCodec::setCodecForCString() в main() без да осъзнават, че това има страничен ефект и причинява заделяне на памет за всеки един C-стринг при сравнение.</p>

	<p>Тъй като сравняването с Latin-1 C-стрингове е често срещано в програмите, Qt предоставя специален клас, наречен QLatin1String, който просто съдържа указател към C-стринг с Latin-1 кодировка. В допълнение, QString предоставя и оператора QString::operator==(const QLatin1String &amp;), който извиква специална функция, която сравнява Уникод стринг и Latin1 стринг. Можем да направим горният код без съмнение по-бърз като напишем:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>fruit<span class="sy0">==</span> <a href="http://developer.qt.nokia.com/doc/QLatin1String.html"><span class="kw5">QLatin1String</span></a><span class="br0">&#40;</span><span class="st0">&quot;apple&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="co1">// бърз и оказва кодировката</span></div></li>
</ol></div></p>

	<p>В кода на Qt, всички сравнения със C-стрингове използват QLatin1String, тъй като приложението може да избере произволен кодек за C-стринговете си.</p>

	<a name="b9002b57db5e71282b41a6266583f863"></a>	<h1>QStringRef : Обработка на стрингове без заделяне на памет</h1>

	<p>QString има множество методи за обработка на стрингове като mid(), left(), right(). Всички те създават нов QString и следователно заделя и копират данни от съществуващия QString. Вместо това могат да се използват QString::midRef(), QString::leftRef() и QString::rightRef(), за да се получи <em>QStringRef</em>. <em>QStringRef</em> е връзка към част от QString. QString също предоставя много предефинирани операции като QString::operator==(const QStringRef &amp;) за оптимална употреба с QStringRef.</p>

	<a name="97952e1e1c25dcdb43b559cc6ed44a99"></a>	<h1>QString::reserve и QString::squeeze</h1>

	<p>По-добре е да заделите повече памет предварително с QString::reserve, така че всяко извикване на QString::append() да не причинява ново заделяне. Допълнителната памет може да освободи по-късно с QString::squeeze.</p>

	<a name="f877da7ebfde3a34e33b417caaa4ab71"></a>	<h1>QStringBuilder : Бързо обединяване на QString-ове</h1>

	<p>Кода по-долу изисква поне 2 заделяния на памет. Първото заделяне е за да се съхрани резултата от &#8220;(&#8221; + type. И след това има още едно заради добавянето на &#8220;)&#8221;. Броят на заделянията се увеличава при всяко следващото извикване на оператора &#8220;+&#8221;.<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>foo.<span class="me1">startsWith</span><span class="br0">&#40;</span><span class="st0">&quot;(&quot;</span> <span class="sy0">+</span> type <span class="sy0">+</span> <span class="st0">&quot;)&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>Допълнителните заделяния на памет могат да бъдат избегнати ако дължината на крайният QString се знае предварително. Qt 4.6 въведе вътрешния клас QStringBuilder, който &#8220;резервира&#8221; памет за събирането на един път. Той постига това като при всяко използване на оператора + по-горе се връща различена клас (не QString). Този клас следи какви стрингове се добавят и колко памет е нужна за тях на всяка стъпка. На края, когато операцията по обединяването се конвертира обратно в QString, класа заделя памет и копира всички стрингове един след друг. Тази възможност може да бъде включена като се използва QT_USE_FAST_CONCATENATION. Когато това е дефинирано, можете да използвате оператора &#8216;%&#8217; вместо &#8216;+&#8217;. Пример:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>foo.<span class="me1">startsWith</span><span class="br0">&#40;</span><span class="st0">&quot;(&quot;</span> <span class="sy0">%</span> type <span class="sy0">%</span> <span class="st0">&quot;)&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
</ol></div></p>

	<p>&#8216;+&#8217; може да се използва вместо &#8216;%&#8217; като се дефинира QT_USE_FAST_OPERATOR_PLUS. Вижте <a href="http://doc.qt.nokia.com/4.6/qstring.html#more-efficient-string-construction">Fast concatenation</a> <em>[doc.qt.nokia.com]</em> за повече детайли</p>

	<a name="bf1a3e2ac7d68d0f7f27e8ffa22da75c"></a>	<h1>QStringMatcher : Бързо търсена на стринг в стринг</h1>

	<p>QStringMatcher може да се използва за търсене на стринг многократно в множество стрингове и в един стринг много пъти. Класът използва &#8220;алгоритъма на Бойър-Муур&#8221;:<a href="http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm">http://en.wikipedia.org/wiki/Boyer–Moore_string_search_algorithm</a> за да извърши бързо търсене.</p>]]></description>
      <dc:subject>UsingQStringEffectively_Bulgarian</dc:subject>
      <dc:date>2012-02-05T21:10:20+00:00</dc:date>
    </item>

    <item>
      <title>PySide_Binaries_MacOSX</title>
      <link>http://developer.qt.nokia.com/wiki/PySide_Binaries_MacOSX</link>
      <guid>http://developer.qt.nokia.com/wiki/PySide_Binaries_MacOSX</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#ad4c17870213170ff94fb9fb2fe29e75">PySide Binaries for Mac OS X</a><ul>
<li><a href="#13715d1b92cfe1756b4213f8093136ef">PySide 1.1.0 / Qt 4.7</a></li>
<li><a href="#8a6eab1cba2ffcf568b36003222e96d5">PySide 1.1.0 / Qt 4.8</a></li>
<li><a href="#e2016c4d75af64b81afc1d5ac20a4b36">MacPorts</a></li></ul>
</li></ul>
</div>

	<p><strong>English</strong> | <a href="http://qt-devnet.developpez.com/tutoriels/python/pyside/installer/?page=osx#VII">French</a> <em>[qt-devnet.developpez.com]</em></p>

	<a name="ad4c17870213170ff94fb9fb2fe29e75"></a>	<h1>PySide Binaries for Mac OS X</h1>

	<p><em>OS X packagers: Markus Ullmann &lt;mail@markus-ullmann.de&gt;</em></p>

	<p>To install PySide in Mac OS X, you have to install both packages:
	<ul>
		<li><a href="http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x">Qt 4.7.4 for Mac OS X</a> <em>[qt.nokia.com]</em></li>
		<li>PySide (See below)</li>
	</ul></p>

	<a name="13715d1b92cfe1756b4213f8093136ef"></a>	<h2>PySide 1.1.0 / Qt 4.7</h2>

	<p><strong><span class="caps">NOTE</span></strong>: This release is now built against Qt 4.7.4. Please update if you have not done so. It includes <span class="caps">QML</span> support and pyside-tools.<br />
<strong><span class="caps">NOTE</span></strong>: The releases now include 32 bit as well as 64 bit libs and thus work everywhere</p>

	<ul>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt47-py27apple.pkg">pyside-1.1.0-qt47-py27apple.pkg</a> <em>[pyside.markus-ullmann.de]</em></li>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt47-py27apple.pkg.bom.txt">contents</a> <em>[pyside.markus-ullmann.de]</em></li>
	</ul>

	<ul>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt47-py26apple.pkg">pyside-1.1.0-qt47-py26apple.pkg</a> <em>[pyside.markus-ullmann.de]</em></li>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt47-py26apple.pkg.bom.txt">contents</a> <em>[pyside.markus-ullmann.de]</em></li>
	</ul>

	<p>Older  releases are available in the <a href="http://pyside.markus-ullmann.de/">archive</a> <em>[pyside.markus-ullmann.de]</em></p>

	<p>Qt for Mac OS X: <a href="http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.7.4.dmg">Download Qt 4.7.4 for Mac OS X</a> <em>[get.qt.nokia.com]</em></p>

	<a name="8a6eab1cba2ffcf568b36003222e96d5"></a>	<h2>PySide 1.1.0 / Qt 4.8</h2>

	<p>For testing purposes there is now a Python 2.7 version built against Qt 4.8.0. Due to Qt only being available in 64bit version, the pyside binaries are built alike.</p>

	<ul>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt48-py27apple.pkg">pyside-1.1.0-qt48-py27apple.pkg</a> <em>[pyside.markus-ullmann.de]</em></li>
		<li><a href="http://pyside.markus-ullmann.de/pyside-1.1.0-qt48-py27apple.pkg.bom.txt">contents</a> <em>[pyside.markus-ullmann.de]</em></li>
	</ul>

	<p>Qt for Mac OS X: <a href="http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.8.0.dmg">Download Qt 4.8.0 for Mac OS X</a> <em>[get.qt.nokia.com]</em></p>

	<a name="e2016c4d75af64b81afc1d5ac20a4b36"></a>	<h2>MacPorts</h2>

	<p>PySide is also available via <a href="http://www.macports.org">MacPorts</a> <em>[macports.org]</em>.</p>]]></description>
      <dc:subject>PySide_Binaries_MacOSX</dc:subject>
      <dc:date>2012-02-05T13:25:37+00:00</dc:date>
    </item>

    <item>
      <title>Mylyn</title>
      <link>http://developer.qt.nokia.com/wiki/Mylyn</link>
      <guid>http://developer.qt.nokia.com/wiki/Mylyn</guid>
      <description><![CDATA[<a name="135c83370584ac210bf22466f56aa890"></a>	<h1>Mylyn Plugin for Qt-Creator</h1>

	<p>Since several months now no changes were commited to this project. The reason is simply the amount of work needed coupled with lack of bugzilla api knowledge. so whoever feels the need to do some coding on this project, please do.</p>

	<p>I searched for a stable webservice api for bugzilla, as i wanted to have at least one working backend for mylyn, alas i didn&#8217;t find any. There is some documentation in the wild, however it doesn&#8217;t seem to be neither reliable nor stable. No idea how the eclipse guys did that.</p>

	<p>Find the project <a href="http://github.com/NoobSaibot/qt-creator/tree/mylyn">on github [broken]</a> <em>[github.com]</em>.</p>]]></description>
      <dc:subject>Mylyn</dc:subject>
      <dc:date>2012-02-05T12:53:37+00:00</dc:date>
    </item>

    <item>
      <title>Simple_QML_Progress_Bar</title>
      <link>http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar</link>
      <guid>http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar_Bulgarian">Български</a></p>

	<a name="782121a35a93ec41fd66a3e6feb118ee"></a>	<h1>Simple Progress Bar</h1>

	<p>This very simple <span class="caps">QML</span> progress bar takes some inspiration form the progress bars example that ships with Qt. I have modified it to be a very plain and lightweight progress bar that is suitable for use even at very small sizes. This is what it looks like by default (with the Qt green colour <span class="smiley">;-)</span> )</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://gallery.theharmers.co.uk/upload/2011/04/30/20110430152206-b395a64a.png" title="Simple progress bar" alt="Simple progress bar" /></p>

	<p>This progress bar is used along with the <a href="http://developer.qt.nokia.com/wiki/Busy_Indicator_for_QML">BusyIndicator</a> <em>[developer.qt.nokia.com]</em> in the ProgressSpinner <span class="caps">QML</span> component to produce a nice <span class="caps">QML</span> component that can show activity and progress for long operations.</p>

	<p>Implementation (SimpleProgressBar.qml):<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; id<span class="sy0">:</span> progressbar</div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> minimum<span class="sy0">:</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> maximum<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> value<span class="sy0">:</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property color color<span class="sy0">:</span> <span class="st0">&quot;#77B753&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">250</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">23</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; clip<span class="sy0">:</span> <span class="kw2">true</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> border</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">bottomMargin</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">rightMargin</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> <span class="st0">&quot;transparent&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; border.<span class="me1">width</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; border.<span class="me1">color</span><span class="sy0">:</span> parent.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> highlight</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; property <span class="kw4">int</span> widthDest<span class="sy0">:</span> <span class="br0">&#40;</span> <span class="br0">&#40;</span> progressbar.<span class="me1">width</span> <span class="sy0">*</span> <span class="br0">&#40;</span> value <span class="sy0">-</span> minimum <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="sy0">/</span> <span class="br0">&#40;</span> maximum <span class="sy0">-</span> minimum <span class="br0">&#41;</span> <span class="sy0">-</span> <span class="nu0">4</span> <span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span> highlight.<span class="me1">widthDest</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Behavior on width <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SmoothedAnimation <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velocity<span class="sy0">:</span> <span class="nu0">1200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; anchors <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left<span class="sy0">:</span> parent.<span class="me1">left</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top<span class="sy0">:</span> parent.<span class="me1">top</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottom<span class="sy0">:</span> parent.<span class="me1">bottom</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margins<span class="sy0">:</span> <span class="nu0">2</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> parent.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Usage:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; id<span class="sy0">:</span> root</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">640</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; SimpleProgressBar <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> progress</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">centerIn</span><span class="sy0">:</span> progressSpinner</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">12</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> progressSpinner.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; value<span class="sy0">:</span> <span class="nu0">35</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>]]></description>
      <dc:subject>Simple_QML_Progress_Bar</dc:subject>
      <dc:date>2012-02-04T09:17:38+00:00</dc:date>
    </item>

    <item>
      <title>Simple_QML_Progress_Bar_Bulgarian</title>
      <link>http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar_Bulgarian</link>
      <guid>http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar_Bulgarian</guid>
      <description><![CDATA[<p><strong>Български</strong> <a href="http://developer.qt.nokia.com/wiki/Simple_QML_Progress_Bar">English</a></p>

	<a name="1609d3c729bf83de703780055b0a50a9"></a>	<h1>Прост прогрес бар</h1>

	<p>Този много прост <span class="caps">QML</span> прогрес бар бе вдъхновен от примера, който идва с Qt. Направен е така, че да е много опростен и лек и да е подходящ дори за много малки размери. Ето така изглежда по подразбиране (със зеленият цвят на Qt <span class="smiley">;-)</span> )</p>

	<p><img onload='imgFitOnLoad(this)'  src="http://gallery.theharmers.co.uk/upload/2011/04/30/20110430152206-b395a64a.png" title="Simple progress bar" alt="Simple progress bar" /></p>

	<p>Този прогрес бар се използва заедно с <a href="http://developer.qt.nokia.com/wiki/Busy_Indicator_for_QML">BusyIndicator</a> <em>[developer.qt.nokia.com]</em> в <span class="caps">QML</span> компонента <strong>ProgressSpinner</strong>, за да  се получи приятен елемент, който може да показва активността и прогреса на дълги операции.</p>

	<p>Реализация (SimpleProgressBar.qml):<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Item <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; id<span class="sy0">:</span> progressbar</div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> minimum<span class="sy0">:</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> maximum<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property <span class="kw4">int</span> value<span class="sy0">:</span> <span class="nu0">0</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; property color color<span class="sy0">:</span> <span class="st0">&quot;#77B753&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">250</span><span class="sy0">;</span> height<span class="sy0">:</span> <span class="nu0">23</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; clip<span class="sy0">:</span> <span class="kw2">true</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> border</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">bottomMargin</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">rightMargin</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> <span class="st0">&quot;transparent&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; border.<span class="me1">width</span><span class="sy0">:</span> <span class="nu0">1</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; border.<span class="me1">color</span><span class="sy0">:</span> parent.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> highlight</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; property <span class="kw4">int</span> widthDest<span class="sy0">:</span> <span class="br0">&#40;</span> <span class="br0">&#40;</span> progressbar.<span class="me1">width</span> <span class="sy0">*</span> <span class="br0">&#40;</span> value <span class="sy0">-</span> minimum <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="sy0">/</span> <span class="br0">&#40;</span> maximum <span class="sy0">-</span> minimum <span class="br0">&#41;</span> <span class="sy0">-</span> <span class="nu0">4</span> <span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span> highlight.<span class="me1">widthDest</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Behavior on width <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SmoothedAnimation <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velocity<span class="sy0">:</span> <span class="nu0">1200</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; anchors <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left<span class="sy0">:</span> parent.<span class="me1">left</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top<span class="sy0">:</span> parent.<span class="me1">top</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottom<span class="sy0">:</span> parent.<span class="me1">bottom</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margins<span class="sy0">:</span> <span class="nu0">2</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> parent.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<p>Употреба:</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">import QtQuick <span class="nu16">1.0</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; id<span class="sy0">:</span> root</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">640</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; SimpleProgressBar <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> progress</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">centerIn</span><span class="sy0">:</span> progressSpinner</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">100</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">12</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; color<span class="sy0">:</span> progressSpinner.<span class="me1">color</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; value<span class="sy0">:</span> <span class="nu0">35</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>]]></description>
      <dc:subject>Simple_QML_Progress_Bar_Bulgarian</dc:subject>
      <dc:date>2012-02-04T09:16:45+00:00</dc:date>
    </item>

    <item>
      <title>How_to_Use_Signals_and_Slots</title>
      <link>http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots</link>
      <guid>http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#3fcc0eb2837b1581495c094908804a6e">How to Use Signals and Slots?</a><ul>
<li><a href="#0b79795d3efc95b9976c7c5b933afce2">Introduction</a></li>
<li><a href="#c2cc7082a89c1ad6631a2f66af5f00c0">Connection</a></li>
<li><a href="#859dbdc5356eaaff5ef28a4e8cf5dc85">Deeper</a></li>
<li><a href="#611114a3a55940e855fb96b973f897fc">See also</a></li></ul>
</li></ul>
</div>

	<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots_SimplifiedChinese">简体中文</a></p>

	<a name="3fcc0eb2837b1581495c094908804a6e"></a>	<h1>How to Use Signals and Slots?</h1>

	<a name="0b79795d3efc95b9976c7c5b933afce2"></a>	<h2>Introduction</h2>

	<p>Remember old X-Window <em>call-back</em> system? Generally it isn&#8217;t type safe and flexible. There are many problems with them. Qt offer new event-handling system &#8211; <em>signal-slot</em> connections. Imagine alarm clock. When alarm is ringing, signal is sending (<em>emitting</em>). And you&#8217;re handling it as a slot.</p>

	<ul>
		<li>Every QObject class may have as many signals of slots as you want.</li>
		<li>You can emit signal only from that class, where signal is.</li>
		<li>You can <em>connect</em> signal with another signal (make chains of signals);</li>
		<li>Every signal and slot can have unlimited count of connections with other.</li>
		<li><strong><span class="caps">ATTENTION</span>!</strong> You can&#8217;t set default value in slot attributes. <em>e.g.</em> <code>void mySlot(int i = 0);</code></li>
	</ul>

	<a name="c2cc7082a89c1ad6631a2f66af5f00c0"></a>	<h2>Connection</h2>

	<p>You can connect signal with this template:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="kw2">connect</span> <span class="br0">&#40;</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> sender<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> <span class="kw4">signal</span><span class="sy0">,</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> receiver<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> method<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div><br />
You have to wrap <em>const char * signal</em> and <em>const char * method</em> into <acronym title=""><span class="caps">SIGNAL</span></acronym> and <acronym title=""><span class="caps">SLOT</span></acronym> macros.</p>

	<p>And you also can disconnect signal-slot:<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="me2">disconnect</span> <span class="br0">&#40;</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> sender<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> <span class="kw4">signal</span><span class="sy0">,</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> receiver<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> method<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<a name="859dbdc5356eaaff5ef28a4e8cf5dc85"></a>	<h2>Deeper</h2>

	<p>Widgets emit signals when events occur. For example, a button will emit a &#8220;clicked&#8221; signal when it is clicked. A developer can choose to connect to a signal by creating a function (a &#8220;slot&#8221;) and calling the <code>connect()</code> function to relate the signal to the slot. Qt&#8217;s signals and slots mechanism does not require classes to have knowledge of each other, which makes it much easier to develop highly reusable classes. Since signals and slots are type-safe, type errors are reported as warnings and do not cause crashes to occur.</p>

	<p>For example, if a Quit button&#8217;s <code>clicked()</code> signal is connected to the application&#8217;s <code>quit()</code> slot, a user&#8217;s click on Quit makes the application terminate. In code, this is written as</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">connect</span><span class="br0">&#40;</span>button<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>clicked<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> qApp<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>quit<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>Connections can be added or removed at any time during the execution of a Qt application, they can be set up so that they are executed when a signal is emitted or queued for later execution, and they can be made between objects in different threads.</p>

	<p>The signals and slots mechanism is implemented in standard C++. The implementation uses the C++ preprocessor and <code>moc</code>, the Meta-Object Compiler, included with Qt. Code generation is performed automatically by sub:Qt&#8217;s-Build-System. Developers never have to edit or even look at the generated code.</p>

	<p>In addition to handling signals and slots, the Meta-Object Compiler supports Qt&#8217;s translation mechanism, its property system, and its extended run-time type information. It also makes run-time introspection of C++ programs possible in a way that works on all supported platforms.</p>

	<a name="611114a3a55940e855fb96b973f897fc"></a>	<h2>See also</h2>

 <a href="http://blog.csdn.net/qter_wd007/article/details/5598264">Qt中的信号与槽详解</a> <em>[blog.csdn.net]</em>]]></description>
      <dc:subject>How_to_Use_Signals_and_Slots</dc:subject>
      <dc:date>2012-02-04T08:53:53+00:00</dc:date>
    </item>

    <item>
      <title>How_to_Use_Signals_and_Slots_SimplifiedChinese</title>
      <link>http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots_SimplifiedChinese</link>
      <guid>http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots_SimplifiedChinese</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#b0bf81d5b209b0c121cf9600ac2b8f9d">怎样使用信号与槽？</a><ul>
<li><a href="#86385379cf9cfbc2c554944f1c054a45">概览</a></li>
<li><a href="#e1ab54780175a6c08c9182b5533e7ca9">信号与槽的连接</a></li>
<li><a href="#64fc7df7cd15be4b74db13e44db700c5">进一步探讨</a></li>
<li><a href="#df24bf62e2ad491f27c2f1217dfb7f74">参见</a></li></ul>
</li></ul>
</div>

	<p><strong>简体中文</strong> <a href="http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots">English</a></p>

	<a name="b0bf81d5b209b0c121cf9600ac2b8f9d"></a>	<h1>怎样使用信号与槽？</h1>

	<a name="86385379cf9cfbc2c554944f1c054a45"></a>	<h2>概览</h2>

	<p>还记得 X-Window 上老旧的回调函数系统吗？通常它不是类型安全的并且很复杂。（使用）它（会）有很多的问题。Qt提供了一种新的事件处理系统－信号-槽。想象一下闹钟（工作的样子）。当闹铃响的时候，它正在发出信号（发射）。而你处理这个事件的过程就类似使用一个槽的样子。</p>

	<ul>
		<li>每个QObject类（或其派生类）的对象都可以含有你能想象到的一样多的信号和槽</li>
		<li>只有定义过这个信号的类或者其派生类能够发射这个信号</li>
		<li>可以把一个槽与另一个槽连接起来（做成信号链）</li>
		<li>每个信号与槽之间可以有无限制数量的连接</li>
		<li><strong>注意：</strong> 不能为槽的参数设置缺省值。例如以下代码是错误的：<br />
<div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw4">void</span> mySlot<span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></li>
	</ul>

	<a name="e1ab54780175a6c08c9182b5533e7ca9"></a>	<h2>信号与槽的连接</h2>

	<p>可以使用下面的模板（原型）连接信号和槽：</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="kw2">connect</span> <span class="br0">&#40;</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> sender<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> <span class="kw4">signal</span><span class="sy0">,</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> receiver<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> method<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div><br />
必须把上式中的const char * signal和const char * method分别放进<acronym title=""><span class="caps">SIGNAL</span></acronym> 和<acronym title=""><span class="caps">SLOT</span></acronym> 这两个宏里面。</p>

	<p>可以像下面那样解除信号和槽的连接：</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a><span class="sy0">::</span><span class="me2">disconnect</span> <span class="br0">&#40;</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> sender<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> <span class="kw4">signal</span><span class="sy0">,</span> <span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span> receiver<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span> method<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<a name="64fc7df7cd15be4b74db13e44db700c5"></a>	<h2>进一步探讨</h2>

	<p>当事件发生时，某个部件（或对象）就会发射信号。比如，当一个按钮部件被点击时，它就会发出&#8220;被点击&#8220;这个信号。开发者可以选择创建一个函数（没错，它就是一个“槽”），并使用<code>connect()</code>来把这个信号与槽关联起来。Qt的信号与槽机制（被设计成）并不要求这些相关的类互相了解，这就使得开发高度可重用的类变得更容易。由于信号与槽是类型安全的，类型错误会以警告的方式（被编译器）报告出来并且不会引起（程序）崩溃。</p>

	<p>举例来说，假如一个Quit按钮的<code>clicked()</code>信号与应用程序的<code>quit()</code>槽相连接，那么当用户点击该Quit按钮时，就会终止这个程序的运行。用代码实现该连接如下：</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="kw2">connect</span><span class="br0">&#40;</span>button<span class="sy0">,</span> SIGNAL<span class="br0">&#40;</span>clicked<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span> qApp<span class="sy0">,</span> SLOT<span class="br0">&#40;</span>quit<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
</ol></div></p>

	<p>在应用程序运行期间的任何时候，信号与槽的连接都可以被添加或移除。它们可以在信号被立即或者安排到以后去发射时建立起来，而且可以用于不同对象间的多线程应用中。</p>

	<p>信号与槽机制是使用标准C++实现的。它使用了C++中的预处理器以及Qt中的<code>moc</code>, 即元对象编译器（ Meta-Object Compiler）。代码的生成由Qt的构建系统（Qt&#8217;s-Build-System）自动完成。开发者几乎不需要浏览或者编辑这些代码。</p>

	<p>除了完成信号与槽的处理，元对象编译器还对Qt的多语言机制、属性系统以及扩展的运行时类型识别提供了支持。它还为C++程序的运行时内省在所有支持的平台上的运行提供了一种途径。</p>

	<a name="df24bf62e2ad491f27c2f1217dfb7f74"></a>	<h2>参见</h2>

 <a href="http://blog.csdn.net/qter_wd007/article/details/5598264">Qt中的信号与槽详解</a> <em>[blog.csdn.net]</em>]]></description>
      <dc:subject>How_to_Use_Signals_and_Slots_SimplifiedChinese</dc:subject>
      <dc:date>2012-02-03T14:40:55+00:00</dc:date>
    </item>

    <item>
      <title>Category:Qt_Supported_Platforms</title>
      <link>http://developer.qt.nokia.com/wiki/Category:Qt_Supported_Platforms</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:Qt_Supported_Platforms</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Platform_Support_Japanese">日本語</a> <a href="http://developer.qt.nokia.com/wiki/Platform_Support_Bulgarian">Български</a></p>

	<a name="4aa02491d3ee690a6a014b190a75060e"></a>	<h1>Supported Platforms</h1>

	<p>Qt is a cross-platform application and UI framework. Using Qt, you can write web-enabled applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code.</p>

	<p>Qt is available for the following platforms:
	<ul>
		<li><a href="Support_for_Windows">Windows Desktop</a></li>
		<li><a href="Support_for_Windows_CE_and_Windows_Mobile">Windows CE and Windows Mobile</a></li>
		<li><a href="Support_for_Linux_X11">Linux/X11</a></li>
		<li><a href="Support_for_Embedded_Linux">Embedded Linux</a></li>
		<li><a href="Support_for_Mac_OS_X">Mac OS X</a></li>
		<li><a href="Support_for_Symbian">Symbian phones</a></li>
		<li><a href="Support_for_Maemo">Nokia N9 smartphone</a></li>
	</ul></p>

	<a name="9f3520c7b95782bf672e200753ac79be"></a>	<h2>Supported platform details</h2>

	<p>The Qt team strives to provide support for the platforms most frequently used by Qt users. We have designed our internal testing procedure to divide platforms into three test categories (Tier 1, Tier 2 and Tier 3) in order to prioritize internal testing and development resources so that the most frequently used platforms are subjected to our most rigorous testing processes. For more information, please see the <a href="http://doc.qt.nokia.com/latest/supported-platforms.html">Qt documentation</a> <em>[doc.qt.nokia.com]</em></p>

	<p>Qt is supported on a variety of 32-bit and 64-bit platforms, and can usually be built on each platform with <span class="caps">GCC</span>, a vendor-supplied compiler, or a third party compiler. Although Qt may be built on a range of platform-compiler combinations, only a subset of these are actively supported by Nokia.</p>

	<p>For more details. please read the <a href="http://doc.qt.nokia.com/latest/supported-platforms.html">documentation</a> <em>[doc.qt.nokia.com]</em></p>]]></description>
      <dc:subject>Category:Qt_Supported_Platforms</dc:subject>
      <dc:date>2012-02-02T10:23:54+00:00</dc:date>
    </item>

    <item>
      <title>Qt_Creator_Releases_Japanese</title>
      <link>http://developer.qt.nokia.com/wiki/Qt_Creator_Releases_Japanese</link>
      <guid>http://developer.qt.nokia.com/wiki/Qt_Creator_Releases_Japanese</guid>
      <description><![CDATA[<p><a href="http://developer.qt.nokia.com/wiki/Qt-Creator-Releases">English</a> <strong>日本語</strong></p>

	<a name="5cb5feabea0a4ce9b58e04b05fbb268b"></a>	<h1>Qt Creator のリリース</h1>

	<p>Qt Creator は Qt 開発者のニーズに適合した、クロスプラットフォームの統合開発環境(<span class="caps">IDE</span>)です。</p>

	<a name="f691573c45962918a360216f6aa1d1af"></a>	<h2>ナイトリースナップショット</h2>

	<p>ナイトリービルドスナップショットは、現在 qt-project.org への移行中のため行われていません。しばらくお待ちください。<br />
Qt Creator のソースは <a href="http://gitorious.org/qt-creator">gitorious.org のプロジェクトページ</a> <em>[gitorious.org]</em> から取得してください。</p>

	<a name="18df2f0a51194dac6654d826739e0db8"></a>	<h2>最新の安定版リリース (2.4.1)</h2>

	<p>詳細は <a href="https://qt.gitorious.org/qt-creator/qt-creator/blobs/v2.4.1/dist/changes-2.4.1">変更履歴</a> <em>[qt.gitorious.org]</em> と <a href="http://labs.qt.nokia.co.jp/2012/02/02/qt-creator-2-4-1-released.html">リリースの記事</a> <em>[labs.qt.nokia.co.jp]</em> を参照してください。</p>

	<ul>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-win-opensource-2.4.1.exe">Microsoft Windows</a> <em>[get.qt.nokia.com]</em></li>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-linux-x86-opensource-2.4.1.bin">Linux 32Bit</a> <em>[get.qt.nokia.com]</em></li>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-linux-x86_64-opensource-2.4.1.bin">Linux 64Bit</a> <em>[get.qt.nokia.com]</em></li>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-mac-opensource-2.4.1.dmg">Mac <span class="caps">OSX</span></a> <em>[get.qt.nokia.com]</em></li>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-2.4.1-src.zip">ソースアーカイブ .zip</a> <em>[get.qt.nokia.com]</em></li>
		<li><a href="http://get.qt.nokia.com/qtcreator/qt-creator-2.4.1-src.tar.gz">ソースアーカイブ .tar.gz</a> <em>[get.qt.nokia.com]</em></li>
	</ul>

	<p><strong><em>注意:</em></strong> Qt Creator に含まれるのは <strong>統合開発環境だけ</strong> です。完全な Qt の開発環境が必要であれば、 <a href="http://qt.nokia.com/downloads-jp"><strong>Qt <span class="caps">SDK</span></strong></a> <em>[qt.nokia.com]</em> を使用してください。Qt <span class="caps">SDK</span> には様々なプラットフォーム向けの Qt Creator と Qt 本体が含まれています。</p>]]></description>
      <dc:subject>Qt_Creator_Releases_Japanese</dc:subject>
      <dc:date>2012-02-02T05:46:40+00:00</dc:date>
    </item>

    <item>
      <title>How to use signals and slots</title>
      <link>http://developer.qt.nokia.com/wiki/How&#45;to&#45;use&#45;signals&#45;and&#45;slots</link>
      <guid>http://developer.qt.nokia.com/wiki/How&#45;to&#45;use&#45;signals&#45;and&#45;slots</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#a7cec14e4e36e6c26e66251a2f72adf7">怎样使用信号和槽？</a><ul>
<li><a href="#86385379cf9cfbc2c554944f1c054a45">概览</a></li></ul>
</li></ul>
</div>

	<p><strong>简体中文</strong> <a href="http://developer.qt.nokia.com/wiki/How_to_Use_Signals_and_Slots">English</a></p>

	<a name="a7cec14e4e36e6c26e66251a2f72adf7"></a>	<h1>怎样使用信号和槽？</h1>

	<a name="86385379cf9cfbc2c554944f1c054a45"></a>	<h2>概览</h2>

	<p>还记得X-Window系统上老旧的回调系统吗？通常它是复杂的并且不是类型安全的。使用它们会带来很多问题。Qt提供了新的事件处理系统—信号-槽的连接可以想象一下闹钟的样子。当闹钟报警时，信号就被发送（发射）。你处理它的做法就像是在使用槽。</p>]]></description>
      <dc:subject>How to use signals and slots</dc:subject>
      <dc:date>2012-02-02T04:15:21+00:00</dc:date>
    </item>

    <item>
      <title>Support_for_Maemo</title>
      <link>http://developer.qt.nokia.com/wiki/Support_for_Maemo</link>
      <guid>http://developer.qt.nokia.com/wiki/Support_for_Maemo</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Support_for_Maemo_Japanese">日本語</a></p>

	<a name="93d9d92c337b6c586b36c9385f4763c9"></a>	<h1>Qt on Maemo/MeeGo</h1>

	<p>Qt is a comprehensive application and UI framework for developing applications for the Nokia N9 (MeeGo Harmattan 1.2) and the Nokia N900 (Maemo 5) phones. These applications can also be deployed to Symbian smart phones and desktop operating systems without rewriting the source code. If you are developing apps for Symbian, Nokia N9, or Nokia N900 phones in most cases, you can use Qt under the free <span class="caps">LGPL</span> licensing option. Qt is cross-platform, and that means that you can use the code from one single code-base and rebuild for all supported platforms.</p>

	<a name="f9b3f5d457886300823d01abc97e7bd2"></a>	<h2>Getting Started on Maemo/MeeGo</h2>

	<ul>
		<li><a href="http://developer.nokia.com/Devices/MeeGo/">Support for the Nokia N9</a> <em>[developer.nokia.com]</em></li>
		<li><a href="http://doc.qt.nokia.com/latest/supported-platforms.html">Supported Maemo/MeeGo platforms</a> <em>[doc.qt.nokia.com]</em> &#8211; Qt support for Maemo/MeeGo versions.</li>
		<li><a href="http://doc.qt.nokia.com/qt-maemo-4.7/requirements-maemo5.html">Qt for Maemo/MeeGo Requirements</a> <em>[doc.qt.nokia.com]</em> &#8211; Software required to run Qt on Maemo/MeeGo.</li>
		<li><a href="http://doc.qt.nokia.com/qt-maemo-4.7/install-maemo5-binary.html">Installing Qt for Maemo/MeeGo</a> <em>[doc.qt.nokia.com]</em> &#8211; Build Qt for Maemo/MeeGo development.</li>
		<li><a href="http://doc.qt.nokia.com/qt-maemo-4.7/platform-notes-maemo5.html">Platform and Compiler Notes</a> <em>[doc.qt.nokia.com]</em> &#8211; Maemo/MeeGo &#8211; Platform specific notes.</li>
		<li><a href="http://doc.qt.nokia.com/latest/gettingstarted.html">Getting started</a> <em>[doc.qt.nokia.com]</em></li>
		<li><a href="http://doc.qt.nokia.com/qt-maemo-4.7/maemo5-with-qt-introduction.html">The Maemo 5 Platform</a> <em>[doc.qt.nokia.com]</em> &#8211; Introduction to Qt</li>
	</ul>

	<a name="fc0cf2647614715ea093a45b30ac7d44"></a>	<h2>Key Features for Nokia N9 and Nokia N950 Development</h2>

	<a name="d80dd411bffa32641b4b1a4ca77f91e4"></a>	<h3>Native Look and Feel</h3>

	<p>For the Nokia N9, Qt Quick Components provide for a full set of UI building blocks that match the N9 UI. For the N900, Qt will detect which theme the device is running and applies the style at runtime to your Qt application. Widgets are optimized for touch screen usage..</p>

	<a name="5798d46096bd4e1c212db878cc73ac2c"></a>	<h3>Graphics Features</h3>

	<p>A powerful paint engine that contain features such as anti-aliasing, gradients, curves and transparency. It also has animation support with timelines and easing curves with hardware acceleration using <span class="caps">ARM</span> <span class="caps">NEON</span> and OpenGL ES 2.0.</p>

	<a name="4ebe3e7733f9c23c76ac25559fc814a1"></a>	<h3>Device Configurations</h3>

	<p>Full support for automatic switching between landscape and portrait mode is provided. They will support input methods, including predictive text input and on-screen keyboard. The applications will also have support for one finger touch events and gestures, and have configurable kinetic scrolling.</p>

	<a name="e2e6db821a493832f8571403ecd4dd71"></a>	<h3>Maemo &#8211; Linux/X11</h3>

	<p>Qt supports a wide range of X11 platform variants, such as: Solaris, <span class="caps">AIX</span>, and HP-UX. Qt for the Nokia N9 and Nokia N900 provides the same Qt modules and features with the same functionality as Qt for X11.</p>

	<a name="982e2473af4d16281c03e778d9ecb696"></a>	<h3>Cross-platform development using Qt Creator</h3>

	<p><img onload='imgFitOnLoad(this)'  src="http://doc.qt.nokia.com/qtcreator-snapshot/images/qtcreator-screenshots.png" title="Qt Creator" alt="Qt Creator" /></p>

	<p><a href="http://doc.qt.nokia.com/qtcreator-snapshot/index.html">Qt Creator</a> <em>[doc.qt.nokia.com]</em> is a complete Cross-platform <span class="caps">IDE</span> included in the Qt <span class="caps">SDK</span>. The <span class="caps">IDE</span> allows programmers to create, build, debug and run Qt applications across all supported platforms. </p>]]></description>
      <dc:subject>Support_for_Maemo</dc:subject>
      <dc:date>2012-02-01T11:44:35+00:00</dc:date>
    </item>

    <item>
      <title>Support_for_Symbian</title>
      <link>http://developer.qt.nokia.com/wiki/Support_for_Symbian</link>
      <guid>http://developer.qt.nokia.com/wiki/Support_for_Symbian</guid>
      <description><![CDATA[<p><strong>English</strong> <a href="http://developer.qt.nokia.com/wiki/Support_for_Symbian_Japanese">日本語</a></p>

<div class="factbox right"><h3>Table of Content</h3><ul>
<li><a href="#db1e1ffc95b00029ed53f63e5e2642a0">Support for Symbian</a><ul>
<li><a href="#f6d617a7e9768180495956179d45bbe1">Qt on Symbian</a></li>
<li><a href="#a4f47986960c0be3f9851c034ce20838">Qt SDK</a></li>
<li><a href="#b1651000eae748f333c1886543a49672">Getting Started on Symbian</a></li>
<li><a href="#c524a4505a18172e3e7f90528d8b83b4">Key Features of Symbian Development</a></li>
<li><a href="#4ebe3e7733f9c23c76ac25559fc814a1">Device Configurations</a></li></ul>
</li></ul>
</div> 

	<a name="db1e1ffc95b00029ed53f63e5e2642a0"></a>	<h1>Support for Symbian</h1>

	<a name="f6d617a7e9768180495956179d45bbe1"></a>	<h2>Qt on Symbian</h2>

	<p>Qt is an integral part of the Symbian platform. The latest Symbian Belle phones include Qt as part of their firmware, and earlier phones have Qt support pre-installed as well. Symbian phones starting from S60 3rd Edition, Feature Pack 1 have had Qt support through downloadable modules. The relevant modules are automatically added via <a href="http://www.developer.nokia.com/Community/Wiki/Nokia_Smart_Installer_for_Symbian">Smart Installer</a> <em>[developer.nokia.com]</em>, which checks for dependencies during installation of Qt-based applications. </p>

	<p>Qt in Symbian is highly integrated to the operating system features, such as graphics and file system. The tight integration increases performance of Qt applications.</p>

	<p>If you are developing apps for Symbian phones and the Nokia N9, in most cases, you can use Qt under the free <span class="caps">LGPL</span> licensing option. Qt is cross-platform, and that means that you can use the code from one single code-base and rebuild for all supported platforms.</p>

	<a name="a4f47986960c0be3f9851c034ce20838"></a>	<h2>Qt <span class="caps">SDK</span></h2>

	<p>Development of Qt apps for Symbian phones is undertaken easily using the <a href="http://qt.nokia.com/downloads">Qt <span class="caps">SDK</span></a> <em>[qt.nokia.com]</em>. The current version (Qt <span class="caps">SDK</span> 1.2) offers features to build applications for Symbian Anna and Symbian Belle phones (as well as the Nokia N9 and desktop platforms) using Qt 4.7.4. Development for earlier versions of the Symbian platform and Qt are possible, using <a href="https://www.developer.nokia.com/info/sw.nokia.com/id/84801bfe-8517-4287-9829-014c6f572127/Qt_SDK_1_1_2.html">Qt <span class="caps">SDK</span> 1.1.2</a> <em>[developer.nokia.com]</em> available from the Nokia Developer website.  </p>

	<a name="b1651000eae748f333c1886543a49672"></a>	<h2>Getting Started on Symbian</h2>

	<ul>
		<li><a href="http://qt.nokia.com/downloads">Get Qt <span class="caps">SDK</span></a> <em>[qt.nokia.com]</em> &#8211; it has all the necessary tools for developing Qt applications for Symbian</li>
		<li><a href="http://doc.qt.nokia.com/qtcreator-snapshot/creator-developing-symbian.html">Read the Qt Creator documentation for Symbian on how connect to your phone to Qt Creator</a> <em>[doc.qt.nokia.com]</em></li>
		<li>Read about easy <a href="http://doc.qt.nokia.com/4.7-snapshot/qtquick.html">UI creation with Qt Quick</a> <em>[doc.qt.nokia.com]</em></li>
		<li>See <a href="http://doc.qt.nokia.com/4.7-snapshot/platform-notes-symbian.html">Symbian Platform Notes</a> <em>[doc.qt.nokia.com]</em></li>
		<li><a href="http://www.developer.nokia.com/Distribute/Packaging_and_signing.xhtml#article1_a">A list of phones that have Nokia Store support for Qt applications</a> <em>[developer.nokia.com]</em></li>
	</ul>

	<p>Other notable topics:
	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/QtMobility_1_2_Whats_New">Qt Mobility 1.2 What&#8217;s New</a></li>
		<li><a href="http://developer.qt.nokia.com/wiki/Qt474CompatibilityIssues">List of compatibility issues in the Qt 4.7.4 Release Bundle</a></li>
	</ul></p>

	<a name="c524a4505a18172e3e7f90528d8b83b4"></a>	<h2>Key Features of Symbian Development</h2>

	<p>In addition to the Qt <span class="caps">SDK</span> and Qt <span class="caps">API</span>, Qt provides you with added functionality for an optimized Symbian development experience.</p>

	<a name="d80dd411bffa32641b4b1a4ca77f91e4"></a>	<h3>Native Look and Feel</h3>

	<p>You can use the Qt Quick Components to create UIs with the native look and feel of the latest Symbian UI. For more information on the UI, see the <a href="http://www.developer.nokia.com/Resources/Library/Symbian_Design_Guidelines/index.html">Symbian Design Guidelines</a> <em>[developer.nokia.com]</em> from Nokia Developer. For software development instructions, refer to the <a href="http://doc.qt.nokia.com/qtquick-components-symbian-1.1/">Qt Quick Components</a> <em>[doc.qt.nokia.com]</em> reference.</p>

	<a name="5798d46096bd4e1c212db878cc73ac2c"></a>	<h3>Graphics Features</h3>

	<p>Qt for Symbian contains a powerful paint engine that provides features such as anti-aliasing, gradients, curves, and transparency. It also has animation support with timelines and easing curves. Graphics rendering is also fully hardware accelerated using OpenVG on Symbian Anna and Belle phones.</p>

	<a name="4ebe3e7733f9c23c76ac25559fc814a1"></a>	<h2 id="DeviceConfigurations">Device Configurations</h2>

	<p>Qt is supported in Symbian phones based on <em>S60 3rd Edition, Feature Pack 1</em> and later. </p>

	<p>S60 3rd Edition Feature Pack 1 and 2 phones support <em>Qt 4.6</em> only. Qt is not pre-installed in these phones and it needs to be installed before an application is deployed. Installation on end user phones is done using <a href="http://www.developer.nokia.com/Community/Wiki/Nokia_Smart_Installer_for_Symbian">Smart Installer</a> <em>[developer.nokia.com]</em>, which is built into applications created using the Qt <span class="caps">SDK</span>. All Nokia Store applications need to be packaged for compatibility with Smart Installer regardless to which Symbian phones or Qt releases the applications are targeted.</p>

	<p><em>S60 5th Edition</em> phones don&#8217;t have Qt pre-installed, so Smart Installer deploys Qt if it&#8217;s not already available. In contrast to S60 3rd Edition, <em>Qt 4.7.3</em> with <em>Qt Quick</em> and <em>Qt Mobility 1.1</em> is supported for S60 5th Edition phones.</p>

	<p><em>Qt 4.7.4</em> is supported for Symbian^3, Symbian Anna, and Symbian Belle (and later) phones only. Smart Installer deployment is used for Symbian^3 and Symbian Anna phones. Symbian Belle has this Qt version in firmware.</p>

<table class="infotable line"><tr style="background:#009900;"><th style="text-align:center;">Platform release</th><th style="text-align:center;" colspan="4">Built-in Qt in device</th><th style="text-align:center;">Smart Installer updateable</th><th style="text-align:center;" colspan="4">Latest Qt version available via Smart Installer</th></tr><tr style="background:#009900;"><td></td><td><strong>Qt</strong></td><td><strong>Qt WebKit</strong></td><td><strong>Qt Mobility</strong></td><td><strong>Qt Quick Components</strong></td><td></td><td><strong>Qt</strong></td><td><strong>Qt WebKit</strong></td><td><strong>Qt Mobility</strong></td><td><strong>Qt Quick Components</strong></td></tr><tr><td>S60 3rd Ed. FP 1 (3.1)</td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td>Yes</td><td><strong>4.6.3</strong></td><td>4.6.3</td><td>1.0.3</td><td> &#8211; </td></tr><tr style="background:#ddd;"><td>S60 3rd Ed. FP 2 (3.2)</td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td>Yes</td><td><strong>4.6.3</strong></td><td>4.6.3</td><td>1.0.3</td><td> &#8211; </td></tr><tr><td>S60 5th Ed. (Symbian^1)</td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td> &#8211; </td><td>Yes</td><td><strong>4.7.3</strong></td><td>4.8.0</td><td>1.1.3</td><td> &#8211; </td></tr><tr style="background:#ddd;"><td>Symbian^3</td><td><strong>4.6.3</strong></td><td>4.6.3</td><td> &#8211; </td><td> &#8211; </td><td>Yes </td><td><strong>4.7.4</strong> (4.7.403)</td><td>2.1.0 (4.8.1) [1]</td><td>1.2.1 [4]</td><td>1.1</td></tr><tr><td>Symbian Anna</td><td><strong>4.7.3</strong></td><td>2.1 (4.8.0)</td><td>1.1.3</td><td> &#8211; </td><td>Yes </td><td><strong>4.7.4</strong> (4.7.403)</td><td>2.1.0 (4.8.1) [1]</td><td>1.2.1 [4]</td><td>1.1</td></tr><tr style="background:#ddd;"><td>Symbian Belle PR1.0 and PR1.01</td><td><strong>4.7.4</strong> (4.7.401 and 4.7.402)</td><td>2.1.1 (4.8.1)</td><td>1.2.0</td><td> &#8211; </td><td>No [2]</td><td>N/A</td><td>N/A</td><td>N/A</td><td>1.1</td></tr><tr><td>Symbian Belle PR1.1 [3] </td><td><strong>4.7.4</strong> (4.7.403)</td><td>2.1.1 (4.8.1)</td><td>1.2.1</td><td> 1.1 </td><td>No [2]</td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr></table>

	<p>Notes of the table:
	<ul>
		<li>Hyphen &#8220;-&#8221; in the table means &#8220;not available&#8221;.</li>
		<li><strong>[1]</strong> reference: Qt 4.7.4 bundle for Symbian^3 and Symbian has currently slightly older Qt WebKit 2.1.0 compared to Symbian Belle devices that have Qt WebKit 2.1.1.</li>
		<li><strong>[2]</strong> reference: Symbian Belle will not receive Qt updates via Smart Installer, Qt will be updated in new OS releases (firmware updates).</li>
		<li><strong>[3]</strong> reference: This firmware release is the basis of the <a href="http://europe.nokia.com/symbian-belle#compatible">Symbian Belle software update</a> <em>[europe.nokia.com]</em> to earlier Symbian^3 and Symbian Anna devices.</li>
		<li><strong>[4]</strong> reference: Qt Mobility 1.2.1 provided by Smart Installer is minor update to Qt Mobility 1.2.0 in-built in Symbian Belle. Belle devices will get Qt Mobility 1.2.1 via firmware update.</li>
		<li>Qt WebKit has two different versioning schemes in Symbian: The Qt WebKit version and technical version. The technical version is given in brackets in the above table after Qt WebKit version. The technical version refers to the one used in Symbian <span class="caps">SIS</span> package and package registry of the device, and it is used in Smart Installer definitions (pkg files), whereas the Qt WebKit version is the one used e.g. in &#8220;Qt WebKit reference documentation:<a href="http://doc.qt.nokia.com/4.7-snapshot/qtwebkit-guide.html&#8221;">http://doc.qt.nokia.com/4.7-snapshot/qtwebkit-guide.html&#8221;</a> and in &#8220;WebKit.org site:<a href="http://trac.webkit.org/wiki/QtWebKit&#8221;.">http://trac.webkit.org/wiki/QtWebKit&#8221;.</a></li>
	</ul></p>

	<p>For more information on which Qt module versions are supported in different Symbian phones, see the <a href="http://doc.qt.nokia.com/qtcreator-snapshot/creator-developing-symbian.html">Symbian development topic from the Qt Creator documentation</a> <em>[doc.qt.nokia.com]</em>.</p>

	<p>All Symbian phones supporting Qt provide for automatic switching between landscape and portrait mode, and touch screen and keypad input as appropriate. Qt is deeply integrated to the native Symbian OS and phone hardware features, such as hardware graphics acceleration.</p>

	<a name="56d6f2a23d8791a4dbdb70e1f17e9424"></a>	<h3>Cross-platform Development Using Qt Creator</h3>

	<p><img onload='imgFitOnLoad(this)'  src="http://doc.qt.nokia.com/qtcreator-snapshot/images/qtcreator-screenshots.png" title="Qt Creator" alt="Qt Creator" /></p>

	<p><a href="http://doc.qt.nokia.com/qtcreator-snapshot/index.html">Qt Creator</a> <em>[doc.qt.nokia.com]</em> is a complete cross-platform <span class="caps">IDE</span> included in the Qt <span class="caps">SDK</span>. The <span class="caps">IDE</span> enables you to create, build, debug, and run Qt applications across all supported platforms. You can have a single project and deploy that to multiple phones: such as Symbian and the Nokia N9 (using the MeeGo 1.2 Harmattan target).</p>

	<p>For more information, please see the <a href="http://doc.qt.nokia.com/4.7-snapshot/">Qt documentation</a> <em>[doc.qt.nokia.com]</em></p>]]></description>
      <dc:subject>Support_for_Symbian</dc:subject>
      <dc:date>2012-02-01T11:38:16+00:00</dc:date>
    </item>

    <item>
      <title>Qt_Creator_Releases</title>
      <link>http://developer.qt.nokia.com/wiki/Qt_Creator_Releases</link>
      <guid>http://developer.qt.nokia.com/wiki/Qt_Creator_Releases</guid>
      <description><![CDATA[<a name="9638389eb9b5fc2370a3068894b3dcd1"></a>	<h1>Qt Creator Releases</h1>

	<p>Qt Creator is a cross-platform integrated development environment (<span class="caps">IDE</span>) tailored to the needs of Qt developers. </p>

	<a name="492e4e12058eb73683f86ce52bf85773"></a>	<h2>Nightly Snapshots</h2>

	<p>The nightly binary snapshots are currently offline, in the light of the move to qt-project.org. We are working on a solution.<br />
For the sources of the project please have a look at the <a href="http://gitorious.org/qt-creator">project on gitorious.org</a> <em>[gitorious.org]</em></p>

	<a name="d8f57d42f0d3beef33ab818a097ce1d5"></a>	<h2>Latest Stable Release (2.4.1)</h2>

	<p>For details please see the <a href="https://qt.gitorious.org/qt-creator/qt-creator/blobs/v2.4.1/dist/changes-2.4.1">change log</a> <em>[qt.gitorious.org]</em> and the <a href="http://labs.qt.nokia.com/?p=7875">release blog</a> <em>[labs.qt.nokia.com]</em> .</p>

	<p><a href="http://get.qt.nokia.com/qtcreator/qt-creator-win-opensource-2.4.1.exe">Microsoft Windows</a> <em>[get.qt.nokia.com]</em><br />
<a href="http://get.qt.nokia.com/qtcreator/qt-creator-linux-x86-opensource-2.4.1.bin">Linux 32Bit</a> <em>[get.qt.nokia.com]</em><br />
<a href="http://get.qt.nokia.com/qtcreator/qt-creator-linux-x86_64-opensource-2.4.1.bin">Linux 64Bit</a> <em>[get.qt.nokia.com]</em><br />
<a href="http://get.qt.nokia.com/qtcreator/qt-creator-mac-opensource-2.4.1.dmg">Mac <span class="caps">OSX</span></a> <em>[get.qt.nokia.com]</em><br />
<a href="http://get.qt.nokia.com/qtcreator/qt-creator-2.4.1-src.zip">Source as .zip</a> <em>[get.qt.nokia.com]</em><br />
<a href="http://get.qt.nokia.com/qtcreator/qt-creator-2.4.1-src.tar.gz">Source as .tar.gz</a> <em>[get.qt.nokia.com]</em></p>

	<ul>
		<li><strong><em>Note:</em></strong> Qt Creator is an <strong><span class="caps">IDE</span> only</strong>. If you need a complete Qt development environment, please use the <a href="http://qt.nokia.com/downloads"><strong>Qt <span class="caps">SDK</span></strong></a> <em>[qt.nokia.com]</em>, and the Qt Creator version and Qt versions for a wide range of platforms provided with this package instead.</li>
	</ul>]]></description>
      <dc:subject>Qt_Creator_Releases</dc:subject>
      <dc:date>2012-02-01T10:33:39+00:00</dc:date>
    </item>

    <item>
      <title>QtConcurrent run free function</title>
      <link>http://developer.qt.nokia.com/wiki/QtConcurrent&#45;run&#45;free&#45;function</link>
      <guid>http://developer.qt.nokia.com/wiki/QtConcurrent&#45;run&#45;free&#45;function</guid>
      <description><![CDATA[<div class="factbox right"><h3>Table of Content</h3><ul>
<ul>
<li><a href="#44807cf64a3c9a6fd24dd0d597a9e73e">form.h</a></li>
<li><a href="#e3609ff810850fe3e81ee496a009c7c8">form.cpp</a></li>
<li><a href="#e6c00dfaa3ec1d38cea937f563fb5c35">form.ui</a></li>
<li><a href="#118fcbaaba162ba17933c7893247df3a">main.cpp</a></li></ul>
</li></ul>
</div>

	<p>To call a free function using QtConcurrent::run, simply pass the function name.</p>

	<a name="44807cf64a3c9a6fd24dd0d597a9e73e"></a>	<h2>form.h</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#ifndef FORM_H</span></div></li>
<li class="li1"><div class="de1"><span class="co2">#define FORM_H</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#include &quot;ui_form.h&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">class</span> Form <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QWidget.html"><span class="kw5">QWidget</span></a><span class="sy0">,</span> <span class="kw2">private</span> Ui<span class="sy0">::</span><span class="me2">Form</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw2">public</span> <span class="kw2">slots</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw4">void</span> on_btnOpen_clicked<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; Form<span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QWidget.html"><span class="kw5">QWidget</span></a> <span class="sy0">*</span>parent <span class="sy0">=</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#endif</span></div></li>
</ol></div></p>

	<a name="e3609ff810850fe3e81ee496a009c7c8"></a>	<h2>form.cpp</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;QtGui&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="co2">#include &lt;QImage&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#include &quot;form.h&quot;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#include &lt;iostream&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Form<span class="sy0">::</span><span class="me2">Form</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QWidget.html"><span class="kw5">QWidget</span></a> <span class="sy0">*</span>parent<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">:</span> <a href="http://developer.qt.nokia.com/doc/QWidget.html"><span class="kw5">QWidget</span></a><span class="br0">&#40;</span>parent<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; setupUi<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> LongFunction<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw4">int</span> count <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> count <span class="sy0">&lt;</span> <span class="nu0">5</span><span class="sy0">;</span> count<span class="sy0">++</span> <span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; sleep<span class="br0">&#40;</span> <span class="nu0">1</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; std<span class="sy0">::</span><span class="kw3">cout</span> <span class="sy0">&lt;&lt;</span> <span class="st0">&quot;Ping long!&quot;</span> <span class="sy0">&lt;&lt;</span> std<span class="sy0">::</span><span class="me2">endl</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> Form<span class="sy0">::</span><span class="me2">on_btnOpen_clicked</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; <a href="http://developer.qt.nokia.com/doc/QFuture.html"><span class="kw5">QFuture</span></a><span class="sy0">&lt;</span><span class="kw4">void</span><span class="sy0">&gt;</span> result <span class="sy0">=</span> QtConcurrent<span class="sy0">::</span><span class="me2">run</span> <span class="br0">&#40;</span> LongFunction <span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="co1">//result.waitForFinished();</span></div></li>
<li class="li1"><div class="de1">&nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; std<span class="sy0">::</span><span class="kw3">cout</span> <span class="sy0">&lt;&lt;</span> <span class="st0">&quot;exit.&quot;</span> <span class="sy0">&lt;&lt;</span> std<span class="sy0">::</span><span class="me2">endl</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>

	<a name="e6c00dfaa3ec1d38cea937f563fb5c35"></a>	<h2>form.ui</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="sy0">&lt;</span>?xml version<span class="sy0">=</span><span class="st0">&quot;1.0&quot;</span> encoding<span class="sy0">=</span><span class="st0">&quot;UTF-8&quot;</span>?<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="sy0">&lt;</span>ui version<span class="sy0">=</span><span class="st0">&quot;4.0&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="sy0">&lt;</span><span class="kw2">class</span><span class="sy0">&gt;</span>Form<span class="sy0">&lt;/</span><span class="kw2">class</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="sy0">&lt;</span>widget <span class="kw2">class</span><span class="sy0">=</span><span class="st0">&quot;QWidget&quot;</span> name<span class="sy0">=</span><span class="st0">&quot;Form&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="sy0">&lt;</span>property name<span class="sy0">=</span><span class="st0">&quot;geometry&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;</span>rect<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">&lt;</span>x<span class="sy0">&gt;</span><span class="nu0">0</span><span class="sy0">&lt;/</span>x<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">&lt;</span>y<span class="sy0">&gt;</span><span class="nu0">0</span><span class="sy0">&lt;/</span>y<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">&lt;</span>width<span class="sy0">&gt;</span><span class="nu0">400</span><span class="sy0">&lt;/</span>width<span class="sy0">&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="sy0">&lt;</span>height<span class="sy0">&gt;</span><span class="nu0">300</span><span class="sy0">&lt;/</span>height<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;/</span>rect<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="sy0">&lt;/</span>property<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="sy0">&lt;</span>property name<span class="sy0">=</span><span class="st0">&quot;windowTitle&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;</span>string<span class="sy0">&gt;</span>Form<span class="sy0">&lt;/</span>string<span class="sy0">&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="sy0">&lt;/</span>property<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="sy0">&lt;</span>layout <span class="kw2">class</span><span class="sy0">=</span><span class="st0">&quot;QVBoxLayout&quot;</span> name<span class="sy0">=</span><span class="st0">&quot;verticalLayout&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;</span>item<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">&lt;</span>widget <span class="kw2">class</span><span class="sy0">=</span><span class="st0">&quot;QPushButton&quot;</span> name<span class="sy0">=</span><span class="st0">&quot;pushButton&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="sy0">&lt;</span>property name<span class="sy0">=</span><span class="st0">&quot;text&quot;</span><span class="sy0">&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="sy0">&lt;</span>string<span class="sy0">&gt;</span>PushButton<span class="sy0">&lt;/</span>string<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="sy0">&lt;/</span>property<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sy0">&lt;/</span>widget<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;/</span>item<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="sy0">&lt;/</span>layout<span class="sy0">&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp;<span class="sy0">&lt;/</span>widget<span class="sy0">&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="sy0">&lt;</span>resources<span class="sy0">/&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="sy0">&lt;</span>connections<span class="sy0">/&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="sy0">&lt;/</span>ui<span class="sy0">&gt;</span></div></li>
</ol></div></p>

	<a name="118fcbaaba162ba17933c7893247df3a"></a>	<h2>main.cpp</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;QApplication&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="co2">#include &lt;QObject&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="co2">#include &lt;QThread&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="co2">#include &lt;iostream&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#include &quot;form.h&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="kw4">int</span> argc<span class="sy0">,</span> <span class="kw4">char</span><span class="sy0">*</span>argv<span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <a href="http://developer.qt.nokia.com/doc/QApplication.html"><span class="kw5">QApplication</span></a> app<span class="br0">&#40;</span>argc<span class="sy0">,</span> argv<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; Form form<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; form.<span class="me1">show</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw1">return</span> app.<span class="me1">exec</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>]]></description>
      <dc:subject>QtConcurrent run free function</dc:subject>
      <dc:date>2012-01-31T20:38:38+00:00</dc:date>
    </item>

    <item>
      <title>How_to_use_a_Flickable_inside_a_Flipable</title>
      <link>http://developer.qt.nokia.com/wiki/How_to_use_a_Flickable_inside_a_Flipable</link>
      <guid>http://developer.qt.nokia.com/wiki/How_to_use_a_Flickable_inside_a_Flipable</guid>
      <description><![CDATA[<p>In a QtQuick application I&#8217;m writing I need a Flipable that has Flickable objects on its front and back.  My solution is to use Press-and-Hold mouse events to toggle on and off the flipping feature of the Flipable.  With flipping disabled, the Flickable objects can receive their flicking events.  I use another Press-and-Hold mouse event on one of the Flickables to re-enable flipping.</p>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co1">// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5</span></div></li>
<li class="li1"><div class="de1">import QtQuick <span class="nu16">1.1</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">Rectangle <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; width<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; height<span class="sy0">:</span> <span class="nu0">360</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; Flipable <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> flipable1</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; property <span class="kw4">bool</span> flipped<span class="sy0">:</span> <span class="kw2">false</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; back<span class="sy0">:</span> Flickable <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentHeight<span class="sy0">:</span> backText.<span class="me1">height</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentWidth<span class="sy0">:</span> backText.<span class="me1">width</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> backText</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span> qsTr<span class="br0">&#40;</span><span class="st0">&quot;Hello Back of the World&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onFlickEnded<span class="sy0">:</span> console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;back flick ended&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onFlickStarted<span class="sy0">:</span> console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;back flick started&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onPressAndHold<span class="sy0">:</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;back enabling flipping&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flipableMouseArea.<span class="me1">toggleEnabled</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; front<span class="sy0">:</span> Flickable <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentHeight<span class="sy0">:</span> frontText.<span class="me1">height</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentWidth<span class="sy0">:</span> frontText.<span class="me1">width</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> frontText</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span class="sy0">:</span> qsTr<span class="br0">&#40;</span><span class="st0">&quot;Hello Front of the World&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onFlickEnded<span class="sy0">:</span> console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;front flick ended&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onFlickStarted<span class="sy0">:</span> console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;front flick started&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onPressAndHold<span class="sy0">:</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;front enabling flipping&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flipableMouseArea.<span class="me1">toggleEnabled</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; transform<span class="sy0">:</span> Rotation <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> rotation</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; origin.<span class="me1">x</span><span class="sy0">:</span> flipable1.<span class="me1">width</span><span class="sy0">/</span><span class="nu0">2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; origin.<span class="me1">y</span><span class="sy0">:</span> flipable1.<span class="me1">height</span><span class="sy0">/</span><span class="nu0">2</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; axis.<span class="me1">x</span><span class="sy0">:</span> <span class="nu0">0</span><span class="sy0">;</span> axis.<span class="me1">y</span><span class="sy0">:</span> <span class="nu0">1</span><span class="sy0">;</span> axis.<span class="me1">z</span><span class="sy0">:</span> <span class="nu0">0</span> &nbsp; &nbsp; <span class="co1">// set axis.y to 1 to rotate around y-axis</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; angle<span class="sy0">:</span> <span class="nu0">0</span> &nbsp; &nbsp;<span class="co1">// the default angle</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; states<span class="sy0">:</span> State <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span class="sy0">:</span> <span class="st0">&quot;back&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PropertyChanges <span class="br0">&#123;</span> target<span class="sy0">:</span> rotation<span class="sy0">;</span> angle<span class="sy0">:</span> <span class="nu0">180</span> <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; when<span class="sy0">:</span> flipable1.<span class="me1">flipped</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; transitions<span class="sy0">:</span> Transition <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NumberAnimation <span class="br0">&#123;</span> target<span class="sy0">:</span> rotation<span class="sy0">;</span> property<span class="sy0">:</span> <span class="st0">&quot;angle&quot;</span><span class="sy0">;</span> duration<span class="sy0">:</span> flipable1.<span class="me1">transitionDuration</span> <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; MouseArea <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span class="sy0">:</span> flipableMouseArea</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchors.<span class="me1">fill</span><span class="sy0">:</span> parent</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onPressAndHold<span class="sy0">:</span> toggleEnabled<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onClicked<span class="sy0">:</span> flipable1.<span class="me1">flipped</span> <span class="sy0">=</span> <span class="sy0">!</span>flipable1.<span class="me1">flipped</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function toggleEnabled<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span class="me1">debug</span><span class="br0">&#40;</span><span class="st0">&quot;flipping toggled by press and hold&quot;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enabled <span class="sy0">=</span> <span class="sy0">!</span> enabled</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></p>]]></description>
      <dc:subject>How_to_use_a_Flickable_inside_a_Flipable</dc:subject>
      <dc:date>2012-01-30T23:48:01+00:00</dc:date>
    </item>

    <item>
      <title>QSortFilterProxyModel_subclass_for_text_alignment_ and_readonly_columns</title>
      <link>http://developer.qt.nokia.com/wiki/QSortFilterProxyModel_subclass_for_text_alignment_&#45;and_readonly_columns</link>
      <guid>http://developer.qt.nokia.com/wiki/QSortFilterProxyModel_subclass_for_text_alignment_&#45;and_readonly_columns</guid>
      <description><![CDATA[<a name="d9f61084567311df94d96d5736a5827c"></a>	<h1>QSortFilterProxyModel subclass for text alignment and readonly columns</h1>

	<p>When using the model/view framework it is not possible to:
	<ol>
		<li>enable or disable different columns of the table</li>
		<li>set text alignment for different columns<br />
For this I created the following code after a thread I posted <a href="http://developer.qt.nokia.com/forums/viewthread/13895/">link</a> <em>[developer.qt.nokia.com]</em>. Here it is the code:</li>
	</ol></p>

	<a name="bf50d5e661106d0abe925af3c2e6f7e7"></a>	<h2>Header</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#ifndef PROXYMODEL_HPP</span></div></li>
<li class="li1"><div class="de1"><span class="co2">#define PROXYMODEL_HPP</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#include &lt;QSortFilterProxyModel&gt;</span></div></li>
<li class="li2"><div class="de2"><span class="co2">#include &lt;QMap&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">class</span> ProxyModel <span class="sy0">:</span> <span class="kw2">public</span> <a href="http://developer.qt.nokia.com/doc/QSortFilterProxyModel.html"><span class="kw5">QSortFilterProxyModel</span></a> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1"><span class="kw2">Q_OBJECT</span></div></li>
<li class="li1"><div class="de1"><span class="co1">// PRIVATE VARIABLES</span></div></li>
<li class="li2"><div class="de2"><a href="http://developer.qt.nokia.com/doc/QMap.html"><span class="kw5">QMap</span></a><span class="sy0">&lt;</span><span class="kw4">int</span><span class="sy0">,</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">Alignment</span><span class="sy0">&gt;</span> alignMap<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QMap.html"><span class="kw5">QMap</span></a><span class="sy0">&lt;</span><span class="kw4">int</span><span class="sy0">,</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span><span class="sy0">&gt;</span> flagMap<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw2">public</span><span class="sy0">:</span></div></li>
<li class="li1"><div class="de1"><span class="co1">// CONSTRUCTOR</span></div></li>
<li class="li2"><div class="de2"><span class="kw2">explicit</span> ProxyModel<span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/QObject.html"><span class="kw5">QObject</span></a> <span class="sy0">*</span>parent <span class="sy0">=</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="sy0">:</span> <a href="http://developer.qt.nokia.com/doc/QSortFilterProxyModel.html"><span class="kw5">QSortFilterProxyModel</span></a><span class="br0">&#40;</span>parent<span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// VIRTUAL FUNCTIONS INHERITED FROM QT SORT FILTER MODEL</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a> data<span class="br0">&#40;</span><span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QModelIndex.html"><span class="kw5">QModelIndex</span></a> <span class="sy0">&amp;</span>index<span class="sy0">,</span> <span class="kw4">int</span> role <span class="sy0">=</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">DisplayRole</span><span class="br0">&#41;</span> const<span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span> flags<span class="br0">&#40;</span><span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QModelIndex.html"><span class="kw5">QModelIndex</span></a> <span class="sy0">&amp;</span>index<span class="br0">&#41;</span> const<span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// PUBLIC FUNCTIONS</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> setAlignment<span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">Alignment</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> setAlignmentToAll<span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">Alignment</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> clearAlignment<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> setFlag<span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> setFlagToAll<span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> clearFlag<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw4">void</span> setEnabled<span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <span class="kw4">bool</span> FLAG<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> setEditable<span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <span class="kw4">bool</span> FLAG<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co2">#endif // PROXYMODEL_HPP </span></div></li>
</ol></div></p>

	<a name="30e40a4bf226b5136d5eecf13e4f2c9f"></a>	<h2>Source file</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1"><span class="co2">#include &quot;proxymodel.hpp&quot;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// ================== DATA ===================</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a> ProxyModel<span class="sy0">::</span><span class="me2">data</span><span class="br0">&#40;</span><span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QModelIndex.html"><span class="kw5">QModelIndex</span></a> <span class="sy0">&amp;</span>index<span class="sy0">,</span> <span class="kw4">int</span> role<span class="br0">&#41;</span> <span class="kw4">const</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// if text alignment is asked for enters</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>role <span class="sy0">==</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">TextAlignmentRole</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="co1">// if the column alignment was set-up for all columns</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>alignMap.<span class="me1">contains</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp;<span class="kw1">return</span> <a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span>alignMap.<span class="me1">value</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="co1">// searches if the column alignment was set-up and returns the flag</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>alignMap.<span class="me1">contains</span><span class="br0">&#40;</span>index.<span class="me1">column</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="kw1">return</span> <a href="http://developer.qt.nokia.com/doc/QVariant.html"><span class="kw5">QVariant</span></a><span class="br0">&#40;</span>alignMap.<span class="me1">value</span><span class="br0">&#40;</span>index.<span class="me1">column</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp;<span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// if the column wasn't found or if alignment wasn't requested returns default QVariant</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">return</span> <a href="http://developer.qt.nokia.com/doc/QSortFilterProxyModel.html"><span class="kw5">QSortFilterProxyModel</span></a><span class="sy0">::</span><span class="me2">data</span><span class="br0">&#40;</span>index<span class="sy0">,</span> role<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setAlignment</span><span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">Alignment</span> flag<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// checks if setAlignmentToAll() was called and, if so, rests alignMap</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>alignMap.<span class="me1">contains</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; clearAlignment<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// inserts flag</span></div></li>
<li class="li2"><div class="de2">&nbsp;alignMap.<span class="me1">insert</span><span class="br0">&#40;</span>index<span class="sy0">,</span> flag<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setAlignmentToAll</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">Alignment</span> flag<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// reset QMap</span></div></li>
<li class="li2"><div class="de2">&nbsp;clearAlignment<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// inserts flag</span></div></li>
<li class="li1"><div class="de1">&nbsp;alignMap.<span class="me1">insert</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,</span> flag<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">clearAlignment</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// deletes all items</span></div></li>
<li class="li1"><div class="de1">&nbsp;alignMap.<span class="me1">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="co1">// ================== FLAGS ==================</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span> ProxyModel<span class="sy0">::</span><span class="me2">flags</span><span class="br0">&#40;</span><span class="kw4">const</span> <a href="http://developer.qt.nokia.com/doc/QModelIndex.html"><span class="kw5">QModelIndex</span></a> <span class="sy0">&amp;</span>index<span class="br0">&#41;</span> <span class="kw4">const</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// if the column alignment was set-up for all columns</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>flagMap.<span class="me1">contains</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="kw1">return</span> flagMap.<span class="me1">value</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// searches if the column alignment was set-up and returns the flag</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>flagMap.<span class="me1">contains</span><span class="br0">&#40;</span>index.<span class="me1">column</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; <span class="kw1">return</span> flagMap.<span class="me1">value</span><span class="br0">&#40;</span>index.<span class="me1">column</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp;<span class="kw1">return</span> <a href="http://developer.qt.nokia.com/doc/QSortFilterProxyModel.html"><span class="kw5">QSortFilterProxyModel</span></a><span class="sy0">::</span><span class="me2">flags</span><span class="br0">&#40;</span>index<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setFlag</span><span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span> flag<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// checks if setFlagToAll() was called and, if so, rests flagMap</span></div></li>
<li class="li2"><div class="de2">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>flagMap.<span class="me1">contains</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; clearFlag<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// inserts flag</span></div></li>
<li class="li1"><div class="de1">&nbsp;flagMap.<span class="me1">insert</span><span class="br0">&#40;</span>index<span class="sy0">,</span> flag<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setFlagToAll</span><span class="br0">&#40;</span><a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemFlags</span> flag<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// reset QMap</span></div></li>
<li class="li1"><div class="de1">&nbsp;clearFlag<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// inserts flag</span></div></li>
<li class="li2"><div class="de2">&nbsp;flagMap.<span class="me1">insert</span><span class="br0">&#40;</span><span class="sy0">-</span><span class="nu0">1</span><span class="sy0">,</span> flag<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">clearFlag</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="co1">// deletes all items</span></div></li>
<li class="li2"><div class="de2">&nbsp;flagMap.<span class="me1">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setEnabled</span><span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <span class="kw4">bool</span> FLAG<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>FLAG<span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2">&nbsp; setFlag<span class="br0">&#40;</span>index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">NoItemFlags</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsSelectable</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsEditable</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsDragEnabled</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsDropEnabled</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsEnabled</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">else</span></div></li>
<li class="li1"><div class="de1">&nbsp; setFlag<span class="br0">&#40;</span>index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">NoItemFlags</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2"><span class="kw4">void</span> ProxyModel<span class="sy0">::</span><span class="me2">setEditable</span><span class="br0">&#40;</span><span class="kw4">unsigned</span> <span class="kw4">int</span> index<span class="sy0">,</span> <span class="kw4">bool</span> FLAG<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">if</span><span class="br0">&#40;</span>FLAG<span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; setFlag<span class="br0">&#40;</span>index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">NoItemFlags</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsSelectable</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsEditable</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsDragEnabled</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsDropEnabled</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsEnabled</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;<span class="kw1">else</span></div></li>
<li class="li1"><div class="de1">&nbsp; setFlag<span class="br0">&#40;</span>index<span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">NoItemFlags</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsSelectable</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsDragEnabled</span> <span class="sy0">|</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">ItemIsEnabled</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span> </div></li>
</ol></div></p>

	<a name="0a52730597fb4ffa01fc117d9e71e3a9"></a>	<h2>Example</h2>

	<p><div class="cpp-qt geshi"><ol><li class="li1"><div class="de1">table_model <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://developer.qt.nokia.com/doc/QSqlTableModel.html"><span class="kw5">QSqlTableModel</span></a><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/QSqlDatabase.html"><span class="kw5">QSqlDatabase</span></a><span class="sy0">::</span><span class="me2">database</span><span class="br0">&#40;</span>connection_name<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">proxyModel <span class="sy0">=</span> <span class="kw1">new</span> ProxyModel<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// TABLE'S PROXY SET-UP</span></div></li>
<li class="li2"><div class="de2">proxyModel<span class="sy0">-&gt;</span><span class="me3">setAlignment</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">AlignCenter</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Align center in both vertical and horizontal the first column</span></div></li>
<li class="li1"><div class="de1">proxyModel<span class="sy0">-&gt;</span><span class="me3">setAlignment</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <a href="http://developer.qt.nokia.com/doc/Qt.html"><span class="kw5">Qt</span></a><span class="sy0">::</span><span class="me2">AlignCenter</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="me1">proxyModel</span><span class="sy0">-&gt;</span><span class="me3">setEditable</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// set the column enabled and selectable but not editable</span></div></li>
<li class="li2"><div class="de2">proxyModel<span class="sy0">-&gt;</span><span class="me3">setEnabled</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// set the column disabled</span></div></li>
<li class="li1"><div class="de1">...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// TABLE MODEL SET-UP</span></div></li>
<li class="li1"><div class="de1">table_model<span class="sy0">-&gt;</span><span class="me3">setTable</span><span class="br0">&#40;</span><span class="st0">&quot;account&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li2"><div class="de2">table_model<span class="sy0">-&gt;</span><span class="me3">select</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// query execution</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="co1">// TABLE VIEW SET-UP</span></div></li>
<li class="li1"><div class="de1">proxyModel<span class="sy0">-&gt;</span><span class="me3">setSourceModel</span><span class="br0">&#40;</span>table_model<span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">ui<span class="sy0">-&gt;</span><span class="me3">tableView</span><span class="sy0">-&gt;</span><span class="me3">setModel</span><span class="br0">&#40;</span>proxyModel<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// the model used for the view is the proxymodel </span></div></li>
</ol></div></p>

	<p>Note that you do not need to connect the proxy with the source model before starting to configure it. It is independent. You can assign infinite (limited by hardware) column properties and apply them to any model (to be tested). You can find all the existant Qt::Alignment and Qt::ItemFlags in Qt documentation.</p>

	<p>In my program, I am using a QSqlRelationalTableModel and when this proxymodel was applied the combo boxes were replaced with text edit boxes on the QTableView… the solution for this you can find it <a href="http://developer.qt.nokia.com/wiki/QSqlRelationalDelegate_subclass_that_works_with_QSqlRelationalTableModel">here</a> <em>[developer.qt.nokia.com]</em>.</p>]]></description>
      <dc:subject>QSortFilterProxyModel_subclass_for_text_alignment_ and_readonly_columns</dc:subject>
      <dc:date>2012-01-30T18:52:41+00:00</dc:date>
    </item>

    <item>
      <title>Category:LanguageBindings &#45;&gt; PySide &#45;&gt; Newbie_Tutorials</title>
      <link>http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Newbie_Tutorials</link>
      <guid>http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Newbie_Tutorials</guid>
      <description><![CDATA[<a name="1b822f92d1ba76edd31f65b6a87451a6"></a>	<h1>PySideSimplicissimus : 10 min newbie to newbie Tutorials</h1>

	<p>Before one can start programming, there always are prerequisites. In the Prerequisites for your convenience provided are a few extant links to it as well as the Hello World example. 
	<ul>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_1_Prerequisites">Prerequisites</a><br />
In the following presented are several small examples.  Unless otherwise noted, they should take about 10 mins. to complete, but it may take longer depending on various factors, including familiarity with PySide.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_2_CloseButton">Close</a><br />
Every main PySide program window can be resised, moved around and it can be closed by clicking the [x] symbol. Many programmers, however, prefer to also have a <strong>button that closes</strong> the program. The following code snippet shows how such close button can be implemented.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_3_AboutBox">About</a><br />
The  example of shows an <strong>about box</strong> with version of Qt, PySide, Python and type of platform. Useful for any program, large or small.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_4_ShowLicence">Show Licence</a><br />
It is obligatory for programs licenced under <strong><span class="caps">GPL</span></strong> (General Public Licence) to enable users to display and read <strong><span class="caps">GPL</span>.</strong>  This <strong><span class="caps">GPL</span></strong> requirement is often overlooked. The following snippet shows how to implement it simply.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_5_Combine">Combine</a><br />
Next presented is the combination of the <strong>CloseButton</strong>, <strong>AboutBox</strong> and <strong>Licence</strong>, all in one program. The program is almost useful &#8211; for instance, I use it to  check about box to  see what version of Python, Qt and PySide I am using. For a newbie, the program may take a little longer than 10 minutes.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_6_AlternativeCombine">Alternative Combine</a><br />
There are more ways to skin a cat than one &#8211; many examples of PySide and PyQt do not use the dual inheritance structure for their programs.  This little tutorial gives an alternative method to structure the &#8220;Combine&#8221; program and avoid multiple inheritance.  Good to know about it. It will probably take little less than 10 minutes.</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySideSimplicissimus_Module_7_CombineAllIn1">Combine All in One</a><br />
This is the last variation of combine.py program, a version which merges ui_combine.py and combine.py into one program. It&#8217;s merit is that the number of files is smaller and files with a warning not to alter them are no longer used.  Next newbie to newbie tutorial will be a little more realistic &#8211; an engineering application</li>
		<li><a href="http://developer.qt.nokia.com/wiki/PySide_Engineering_Application">Practical (Almost) Engineering Application</a><br />
The promises have to be kept (I could never be a polititcian) &#8211; so here is an <strong>almost practical</strong> application to analysis of engineering structures, a familiar field of Civil and Aeronautical Engineering. It is a short and straight forward program, though it will take a longer than 10 minutes  <span class="smiley">:)</span></li>
	</ul></p>

	<p><strong>Enjoy!</strong> </p>]]></description>
      <dc:subject>Category:LanguageBindings &#45;&gt; PySide &#45;&gt; Newbie_Tutorials</dc:subject>
      <dc:date>2012-01-30T17:46:50+00:00</dc:date>
    </item>

    
    </channel>
</rss>
