Qt SDK

_images/qt-0.png
Qt is a cross-platform application framework that is used for developing application software with a graphical user interface (GUI).
Qt Creator is a cross-platform C++ IDE, it includes a visual debugger and an integrated GUI layout and forms designer.
The versions used in this SDK are Qt SDK 4.7.4 and Qt Creator 2.4.0.
It is possible to compile applications for x86 and ARM processors.
You can debug the program on the virtual machine or on Pengwyn Board.

Note

Before reading this Chapter you should be able to use HOB, bitbake, and minicom (or a similar program).

Build image with qt

  1. With HOB or bitbake build qt4e-demo-image. To see how to do this, refer to How to use HOB and/or How to use Poky Chapters.
  2. Once the image has been built (and assuming your current build directory is /home/architech/architech_sdk/architech/pengwyn/yocto/build/), run the following commands:
  Host    select
cd /home/architech/architech_sdk/architech/pengwyn/sysroot/
sudo rm -rf *
cp /home/architech/architech_sdk/architech/pengwyn/yocto/build/tmp/deploy/images/qt4e-demo-image-pengwyn.tar.gz .
sudo tar -xzf qt4e-demo-image-pengwyn.tar.gz
  1. Open file /home/architech/architech_sdk/architech/pengwyn/sysroot/etc/inittab and comment line 41:
  Host    select
# 1:2345:respawn:/sbin/getty 38400 tty1

this allows a USB keyboard to be seen by your Qt application.

  1. We don’t need the qt demo application to start at boot, run the following command:
  Host    select
sudo rm /home/architech/architech_sdk/architech/pengwyn/sysroot/etc/init.d/qt4demo

Hello World!

The purpose of this example project is to generate a form with an “Hello World” label in it, at the beginning on the x86 virtual machine and than on the Pengwyn board.

To create the project follow these steps:

  1. Launch Qt Creator from the Architech Splashscreen just clicking on Develop with Qt Creator
_images/qtCreatorStart.jpg
  1. Go to File -> Open File or Project to open QtHelloWorld.pro file located in ~/architech_sdk/architech/pengwyn/workspace/qt/QtHelloWorld/ directory.
  2. Click on “QtHelloWorld” icon to open project menu.
_images/qt-1.png
  1. Select the build configuration: Qt 4.7.4 (Qt-4.7.4) Debug.
_images/qt-2.png
  1. To build the project, click on the bottom-left icon.
_images/qt-3.png
  1. Once you built the project, click on the green triangle to run it.
_images/qt-4.png
  1. Congratulations! You just built your first Qt application for x86.
_images/qt-5.png

In the next section we will debug our Hello World! application directly on Pengwyn.

Debug Hello World project on pengwyn board

  1. Select build configuration: Qt 4.7.4 (Qt-4.7.4-arm) Debug and build the project.
_images/qt-10.png
  1. Copy the generated executable to ~/architech_sdk/architech/pengwyn/sysroot/home/root.
  Host    select
sudo cp ~/architech_sdk/architech/pengwyn/workspace/qt/QtHelloWorld-build-desktop-Qt_4_7_4__Qt-4_7_4-arm__Debug/QtHelloWorld ~/architech_sdk/architech/pengwyn/sysroot/home/root
  1. Copy all files from ~/architech_sdk/architech/pengwynsysroot to rootfs of the sdcard.
  Host    select
sudo cp -r * /media/path/to/rootfs

Then turn on the pengwyn board.

  1. Use minicom to launch gdbserver application on the target board:
  Board    select
gdbserver :10000 QtHelloWorld -qws
  1. In Qt Creator, open the source file main.cpp and set a breakpoint at line 6.
    To do this go with the mouse at line 6 and click with the right button to open the menu, select Set brackpoint at line 6
_images/qt-6.png
  1. Go to Debug→Start Debugging→Attach To Remote Debug Server, a form named “Start Debugger” will appear, insert the following data:
_images/qt-7.jpg
  • Debugger: /opt/poky/1.2.1/sysroots/i686-pokysdk-linux/usr/bin/armv5te-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  • Local executable: /home/architech/architech_sdk/architech/pengwyn/workspace/qt/QtHelloWorld-build-desktop-Qt_4_7_4__Qt-4_7_4-arm__Debug/QtHelloWorld
  • Host and port: 192.168.0.10:10000
  • Architecture: arm
  • GNU target: auto
  • Sysroot: /home/architech/architech_sdk/architech/pengwyn/sysroot

Press OK button to start the debug.

_images/qt-8.png
  1. The hotkeys to debug the application are:
  • F10: Step over
  • F11: Step into
  • Shift + F11: Step out
  • F5: Continue, or press this icon:
_images/qt-9.png
  1. To successfully exit from the debug it is better to close the graphical application from the target board with the mouse by clicking on the ‘X’ symbol.