Gernot Walzl

Qt

Qt is a cute framework for creating graphical user interfaces (GUIs).

Using the provided project template, getting started with Qt development is easy.

Contents

Prerequisites

C++ build tools

Debian

Install build tools using apt:

sudo apt install build-essential
Windows

Download and install Visual Studio Build Tools.
The whole Visual Studio (IDE) is not needed. The build tools are sufficient.

https://visualstudio.microsoft.com/downloads/

Python & Conan

Debian

Install Python using apt:

sudo apt install python3 python3-pip

Install Conan using pip:

pip3 install conan
Windows

Download and install Python:

https://www.python.org/downloads/

Install Conan using pip:

pip install conan

Qt Creator (IDE)

Debian

Install Qt Creator using apt:

sudo apt install qtcreator
Windows

Download and install Qt Creator:

https://download.qt.io/official_releases/qtcreator/

You do not need to register during installation if you enter a proxy that does not work.

Building a Conan package of Qt

Download the package recipe for Qt to a folder named qt:

mkdir qt
curl https://gernot-walzl.at/C++/Qt/conanfile.py -o qt/conanfile.py

Create the package by specifying the directory with the recipe:

conan create qt

Building Qt may take an hour.

Building the example / project template

Download the project template and extract it:

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

Build the project:

mkdir build
cd build
conan install -g virtualrunenv ..
conan build ..

Executing the binary

The built executable is linked against shared libraries. Launching the executable,
requires these shared libraries to be found. By activating the virtual environment,
environment variables (e.g. PATH) are set so that the correct libraries are found.

If the environment has been activated, (conanrunenv) is shown at the command prompt.

Debian

Activate the environment and execute the binary:

cd build
source activate_run.sh
./bin/HelloQt
Windows

Activate the environment and execute the binary:

cd build
activate_run.bat
bin\Release\HelloQt.exe

Using Qt Creator for development

The environment (conanrunenv) enables Qt Creator to automatically detect
settings used for building and running the project.

Debian

Activate the environment and launch Qt Creator:

cd build
source activate_run.sh
qtcreator
Windows

Activate the environment and launch Qt Creator:

cd build
activate_run.bat
qtcreator

Creating a portable zip of the executable

Export the package:

cd build
conan export-pkg ..

Because of the scm attribute in the package recipe conanfile.py,
the package can only be exported if the source code is part of a git repository.

Install the binary package in a folder called dist:

mkdir dist
cd dist
conan install HelloQt/0.1.0@_/_

By calling conan install, the deploy method of the package recipe conanfile.py
copies the executable and all required shared libraries.

Create a zip of the folder containing the binaries:

zip -r HelloQt-0.1.0.zip HelloQt
CONTENT.html source 2022-05-30 5.3 KB
HelloQt-0.1.0.tar.gz sha256 2020-12-16 2.2 KB
conanfile.py source 2020-12-16 4.1 KB
from conans import ConanFile, tools
import shutil
class QtConan(ConanFile):
name = "qt"
version = "5.12.10"