QT Creator Setup
Our data logging system has the possibility to connect an external screen, this can be utilized to inform the pilot of our solar boat about critical information such as the incoming and outgoing power. Creating a user interface is quite important for this purpose as reading lines of text from a terminal is not only difficult but is also quite terrible at drawing the pilots attention to the most important information. To create our graphical user interface we used Qt, Qt is a library for c++ code and provides an open-source library for non-commercial projects. Building Qt applications for our datalogging system requires setting up a toolchain, this document walks through the setting up of said toolchain to quick start Qt application creation for the EoI-Datalogging system. If you plan to develop for any other embedded Linux system this guide may provide you with some information as well as much of it is not system-specific.
This guide is a follow up of EoI-Datalogger-Filesystem, here it is explained why we want to cross-compile Qt for the datalogging system.
Cross-compiling Qt
This guide has been created using Debian 10 as the host computer for Qt v5.14.0
1. Install Qt on the host computer (PC / Laptop)
2. Install dependencies
sudo apt install build-essential libgl1-mesa-dev libglu1-mesa-dev qt5-default libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
3. Add the linux-eoi-datalogger-g++ mkspec to ~/Qt/5.14.0/Src/qtbase/mkspec/devices
mkdir ~/Qt/5.14.0/Src/qtbase/mkspec/devices/linux-eoi-datalogger-g++ cd ~/Qt/5.14.0/Src/qtbase/mkspec/devices/linux-eoi-datalogger-g++ wget https://git.engineersofinnovation.nl/datalogger/qt-tools/-/raw/master/linux-eoi-datalogger-g++/qmake.conf wget https://git.engineersofinnovation.nl/datalogger/qt-tools/-/raw/master/linux-eoi-datalogger-g++/qplatformdefs.h
4. Mount the Debian filesystem at ~/Documents/rootfs/rootfs
5. Fix some symbolc links
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py sudo chmod +x ./sysroot-relativelinks.py sudo ./sysroot-relativelinks.py ~/Documents/datalogger/rootfs/rootfs
6. Start the cross-compilation
mkdir ~/Documents/datalogger/qt-build cd ~/Documents/datalogger/qt-build ~/Qt/5.14.1/Src/qtbase/configure -opengl es2 -device linux-eoi-datalogger-g++ -device-option CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -sysroot ~/Documents/datalogger/rootfs/rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/Qt/5.14.1 -hostprefix ~/Qt/5.14.0/EoI-Datalogger sudo make sudo make install
7. Build the Qt modules
cd ~/Qt/5.14.1/Src/qtdeclarative ~/Qt/5.14.1/EoI-Datalogger/bin/qmake . sudo make sudo make install
cd ~/Qt/5.14.1/Src/qtquickcontrols ~/Qt/5.14.1/EoI-Datalogger/bin/qmake . sudo make sudo make install
cd ~/Qt/5.14.1/Src/qtquickcontrols2 ~/Qt/5.14.1/EoI-Datalogger/bin/qmake . sudo make sudo make install
cd ~/Qt/5.14.1/Src/qtgraphicaleffects ~/Qt/5.14.1/EoI-Datalogger/bin/qmake . sudo make sudo make install
cd ~/Qt/5.14.1/Src/qtserialbus ~/Qt/5.14.1/EoI-Datalogger/bin/qmake . sudo make sudo make install
Setting up QtCreator
- Download and Install QtCreator
- Open QtCreator
- Set up the compiler(s) under
Tools -> Options -> Kits -> Compilers -> Add -> GCC
- Select /usr/bin/arm-linux-gnueabihf-gcc and /usr/bin/arm-linux-gnueabihf-g++
- Add the newly generated Qt version under
Tools -> Options -> Kits -> Qt Versions -> Add
- Navigate to the installation location on the host and select the qmake file (~/Qt/5.14.0/EoI-Datalogger/bin/qmake)
- Add a new kit for the custom target
Tools -> Options -> Kits -> Kits -> Add
- Select the following options and name the kit appropriately
- Device type: Generic Linux Device
- Compiler: The previously added arm-linux-gnueabihf- compilers
- Qt Version: The previously added Qt version
With Qt Creator now setup you can start developing applications, optionally Qt can deploy applications over SSH to the target machine but this is left up to the user
FAQ
Q: I Don't see any text (Fonts) in my application
A: This is a common issue with Qt, on the target device install fonts-dejavu and export the path to provide Qt with fonts before running the application
apt install fonts-dejavu export QT_QPA_FONTDIR=/usr/share/fonts/truetype/dejavu