Implementation of Qt5 application - cu-ecen-aeld/yocto-assignments-base GitHub Wiki
Overview
The purpose of this page is to describe the implementation of a simple Qt5 C++ Graphical User Interface (GUI) application deployed with Yocto based distribution on target hardware. The Yocto image used here is the Core-image-sato which is a graphical image that provides X-11 support that includes the OpenedHand Sato user experience for mobile devices.
Qt framework
- Qt is a cross-platform framework that is usually used as a graphical toolkit and also for creating CLI applications. Qt has an impressive collection of modules such as QtCore, QTWidgets, QtNetwork, QtSQL, QtWebKit etc. which you can use in your project application.
- We will be using qmake utility developed by qt for compiling our qt5 application. The qmake specification will be written in our qt5 project’s .pro files.
Your qt5 project should have the following basic structure to be used with the qmake utlity –- main.cpp - The project's main C++ file containing the main function.The name of this file is a convention, not a requirement.
- {yourclass}.h and {yourclass}.cpp - C++ class header and implementation files for a class that you derived from QObject (if needed). Expand and add classes according to your project application.
- .pro file - contains specifications for Qmake
Steps for Implementation
-
Write your Qt5 application in C++ (Standard can be C++14 or C++17) specific to your project application. To reduce the testing of the application by deploying, flashing, and running the image for every application change you make, one can use QtCreator IDE to compile and run the application natively before deploying on target hardware. However, one can face scalability issues depending on the display (see references).
-
Setup the Yocto environment for the build -
- Host environment should be installed with necessary packages
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat cpio python3 python3-pip python3-pexpect \ xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ pylint3 xterm
- Add yocto base from AESD assignment repo -
git remote add yocto-assignments-base https://github.com/cu-ecen-5013/yocto-assignments-base.git git fetch yocto-assignments-base
- Merge with master branch
git merge yocto-assignments-base/master
- Add necessary meta layers –
git submodule add https://git.yoctoproject.org/git/meta-raspberrypi meta-raspberrypi git submodule add https://git.openembedded.org/meta-openembedded meta-openembedded git submodule add git://git.yoctoproject.org/poky poky git submodule add https://github.com/meta-qt5/meta-qt5.git
-
Create a recipe to install the Qt5 application on the target image. The recipe should inherit the qmake5 class which your Qt application will be compiled with. Ensure that you include all the modules necessary for the application with DEPENDS call.
-
Modify build.sh script to accommodate the new meta layers and the GUI layer with the above recipe.
References
qmake
Qt programming Basics
Qt scalability issues
Yocto & Qt5