<p>
Qt is a cute framework for creating graphical user interfaces (GUIs).
</p>
<p>
Using the provided <a href="./HelloQt-0.1.0.tar.gz" download>project template</a>, getting started with Qt development is easy.
</p>

<h3>Contents</h3>
<ul>
<li><a href="#prerequisites">Prerequisites</a>
<ul>
<li><a href="#prerequisites_tools">C++ build tools</a></li>
<li><a href="#prerequisites_conan">Python &amp; Conan</a></li>
<li><a href="#prerequisites_qtcreator">Qt Creator (IDE)</a></li>
</ul>
</li>
<li><a href="#conan-qt">Building a Conan package of Qt</a></li>
<li><a href="#template">Building the example / project template</a></li>
<li><a href="#executing">Executing the binary</a></li>
<li><a href="#qtcreator">Using Qt Creator for development</a></li>
<li><a href="#portable">Creating a portable zip of the executable</a></li>
</ul>

<h3 id="prerequisites">Prerequisites</h3>

<h4 id="prerequisites_tools">C++ build tools</h4>
<h5>Debian</h5>
<p>
Install build tools using apt:
</p>
<pre><code class="language-bash">sudo apt install build-essential</code></pre>
<h5>Windows</h5>
<p>
Download and install Visual Studio Build Tools.<br />
The whole Visual Studio (IDE) is not needed. The build tools are sufficient.
</p>
<p>
<a href="https://visualstudio.microsoft.com/de/downloads/" target="_blank">
https://visualstudio.microsoft.com/downloads/</a>
</p>

<h4 id="prerequisites_conan">Python &amp; Conan</h4>
<h5>Debian</h5>
<p>Install Python using apt:</p>
<pre><code class="language-bash">sudo apt install python3 python3-pip</code></pre>
<p>Install Conan using pip:</p>
<pre><code class="language-bash">pip3 install conan</code></pre>
<h5>Windows</h5>
<p>Download and install Python:</p>
<p>
<a href="https://www.python.org/downloads/" target="_blank">
https://www.python.org/downloads/</a>
</p>
<p>Install Conan using pip:</p>
<pre><code class="language-bash">pip install conan</code></pre>

<h4 id="prerequisites_qtcreator">Qt Creator (IDE)</h4>
<h5>Debian</h5>
<p>Install Qt Creator using apt:</p>
<pre><code class="language-bash">sudo apt install qtcreator</code></pre>
<h5>Windows</h5>
<p>Download and install Qt Creator:</p>
<p>
<a href="https://download.qt.io/official_releases/qtcreator/" target="_blank">
https://download.qt.io/official_releases/qtcreator/</a>
</p>
<p>
You do not need to register during installation if you enter a proxy that does not work.
</p>

<h3 id="conan-qt">Building a Conan package of Qt</h3>
<p>
Download the <a href="./conanfile.py" download>package recipe for Qt</a> to a folder named <code>qt</code>:
</p>
<pre><code class="language-bash">mkdir qt
curl https://gernot-walzl.at/C++/Qt/conanfile.py -o qt/conanfile.py
</code></pre>
<p>
Create the package by specifying the directory with the recipe:
</p>
<pre><code class="language-bash">conan create qt</code></pre>
<p>
Building Qt may take an hour.
</p>

<h3 id="template">Building the example / project template</h3>
<p>
Download the <a href="./HelloQt-0.1.0.tar.gz" download>project template</a> and extract it:
</p>
<pre><code class="language-bash">curl https://gernot-walzl.at/C++/Qt/HelloQt-0.1.0.tar.gz -o HelloQt-0.1.0.tar.gz
tar xvf HelloQt-0.1.0.tar.gz
cd HelloQt
</code></pre>
<p>
Build the project:
</p>
<pre><code class="language-bash">mkdir build
cd build
conan install -g virtualrunenv ..
conan build ..
</code></pre>

<h3 id="executing">Executing the binary</h3>
<p>
The built executable is linked against shared libraries. Launching the executable,<br />
requires these shared libraries to be found. By activating the virtual environment,<br />
environment variables (e.g. PATH) are set so that the correct libraries are found.
</p>
<p>
If the environment has been activated, <code>(conanrunenv)</code> is shown at the command prompt.
</p>
<h5>Debian</h5>
<p>Activate the environment and execute the binary:</p>
<pre><code class="language-bash">cd build
source activate_run.sh
./bin/HelloQt
</code></pre>
<h5>Windows</h5>
<p>Activate the environment and execute the binary:</p>
<pre><code class="language-dos">cd build
activate_run.bat
bin\Release\HelloQt.exe
</code></pre>

<h3 id="qtcreator">Using Qt Creator for development</h3>
<p>
The environment <code>(conanrunenv)</code> enables Qt Creator to automatically detect<br />
settings used for building and running the project.
</p>
<h5>Debian</h5>
<p>Activate the environment and launch Qt Creator:</p>
<pre><code class="language-bash">cd build
source activate_run.sh
qtcreator
</code></pre>
<h5>Windows</h5>
<p>Activate the environment and launch Qt Creator:</p>
<pre><code class="language-dos">cd build
activate_run.bat
qtcreator
</code></pre>

<h3 id="portable">Creating a portable zip of the executable</h3>
<p>
Export the package:
</p>
<pre><code class="language-bash">cd build
conan export-pkg ..
</code></pre>
<p>
Because of the scm attribute in the package recipe <code class="filename">conanfile.py</code>,<br />
the package can only be exported if the source code is part of a git repository.
</p>
<p>
Install the binary package in a folder called <code>dist</code>:
</p>
<pre><code class="language-bash">mkdir dist
cd dist
conan install HelloQt/0.1.0@_/_
</code></pre>
<p>
By calling <code>conan install</code>, the deploy method of the package recipe <code class="filename">conanfile.py</code><br />
copies the executable and all required shared libraries.
</p>
<p>
Create a zip of the folder containing the binaries:
</p>
<pre><code class="language-bash">zip -r HelloQt-0.1.0.zip HelloQt</code></pre>