Skip to content
Frank Bauernöppel edited this page Nov 30, 2018 · 38 revisions

Qt is a great framework for creating (not only) embedded applications with appealing GUIs. The apps are traditionally written in C++, but GUI design can be done in QML, a descriptive language. There is a rich library of platform independent C++ classes, somehow comparable to JAVA or .NET. Read more on the homepage https://www.qt.io/.

Image with Qt5

The rpi-avg-image can be built with Qt5 support: LinuxFB (framebuffer) and EGLFS ( EGL) are configured as QPAs (Qt Platform Abstraction) and OpenGL ES 2.0 (OpenGL) is used for hardware accelerated drawing.

Check that the Qt5 related packages are included in the rpi-image-avg.bb recipe, like:

IMAGE_INSTALL_append += " \
    packagegroup-qt5-toolchain-target \
"

This packagegroup contains a rather long list of modules, so you might want to select your favorites here.

For bitbake, the currently used branch of the Qt5 layer git://github.com/meta-qt5/meta-qt5.git must be cloned parallel to the other layers in the recipes folder and added to bblayers.conf.

Read more about using the meta-qt5 layer: https://doc-snapshots.qt.io/qtfordevicecreation-5.11/qtee-meta-qt5.html

Qt examples

rpi-avg-image comes with several cimematicExperience examples:

  • qt5-opengles2-test -platform eglfs
  • Qt5_CinematicExperience -platform eglfs
  • BasicQuick -platform eglfs
  • pushd /usr/share/qtsmarthome-1.0/; ./smarthome -platform eglfs; popd

You might have to specify the correct graphical backend for running the examples like:

export QT_QPA_PLATFORM=eglfs
root@raspberrypi3:~# /usr/share/cinematicexperience-1.0/Qt5_CinematicExperience 

or alternatively specify it on the command line like:

root@raspberrypi3:~# /usr/share/cinematicexperience-1.0/Qt5_CinematicExperience -platform eglfs

On the HDMI monitor, you should see a smooth rendering with 60 fps and, with htop, only a moderate CPU usage of some 20%.

http://www.jumpnowtek.com/rpi/Qt5-and-QML-Development-with-the-Raspberry-Pi.html has a small app qqtest which can be used for a first GUI test including a USB mouse for input.

Build your own image containing the Qt framework

Make sure that qtbase is configured with eglfs, gles2 and linuxfb. See https://github.com/jumpnow/meta-rpi/blob/rocko/recipes-qt/qt5/qtbase_git.bbappend. A nearby recipe https://github.com/jumpnow/meta-rpi/blob/rocko/recipes-qt/qt5-env/files/qt5-env.sh shows hot to automate path and environment settings.

Build a demo app on RasPi

see the qqtest example under Building Qt Apps on the RPi in https://jumpnowtek.com/rpi/Qt5-and-QML-Development-with-the-Raspberry-Pi.html

Build (cross-compile) a test app on the build host.

From a bitbake shell:

frank@FrankBuntuSSD:~/raspi/build$ bitbake qt5-opengles2-test

The output package resides in one of the ${BUILDDIR}/tmp/deploy/ipk/* folders. This time we don't use the package server, but a mere copy over the network (adjust IP address accordingly):

frank@FrankBuntuSSD:~/raspi/build$ scp ${BUILDDIR}/tmp/deploy/ipk/*/qt5-opengles2-test_1.0.4*.ipk [email protected]:/home/root

On the RasPi install the package:

root@raspberrypi3:~# opkg install qt5-opengles2-test_1.0.4+gitr0+9383905070-r0_cortexa7hf-neon-vfpv4.ipk 

and start it:

root@raspberrypi3:~# qt5-opengles2-test 

Watch the output on an attached HDMI monitor. Its a quite simple test app only, but it demonstrates that all APIs needed are functional. I might be useful to study its recipe under sources/meta-qt5/recipes-qt/examples/qt5-opengles2-test_git.bb.

further reading

Clone this wiki locally