Chapter 11 describes how you can use Qt in your BBB projects and Qt Creator is a tool that can greatly improve your programming experiences. For example, Figure 11-9 in the book illustrates Qt Creator in action for the creation of the Temperature Sensor application user interface. The videos that are linked below can help you get started with “embedded Qt” but this short text describes how you can get started with Qt Creator itself — with a particular emphasis on using the latest version of Qt Creator with the historical version of Qt (4.8.x) that is required for cross-compilation for the version that is currently (Jan’15) on the BeagleBone.
Step 1. Install Qt Creator
You can download and install the latest version of Qt Creator directly from the address: http://download.qt.io/snapshots/qtcreator/
In my case, I am installing Qt Creator 3.3.x for Linux (on my 64-bit Debian image) as this allows for cross-compilation support. Currently I am downloading a binary with the name: qt-creator-opensource-linux-x86_64-master.run, which is approximately 84MB in size. Once downloaded, this binary can be installed on the desktop computer:
molloyd@debian:~$ cd ~/Downloads/
molloyd@debian:~/Downloads$ ls -l
-rw-r----- 1 molloyd molloyd 87845567 Jan 11 23:20 qt-creator-opensource-linux-x86_64-master.run
molloyd@debian:~/Downloads$ chmod ugo+x qt-creator*
This installs Qt Creator 3.3.x — in my case I installed it in the user directory ~/qtcreator-3.3.81/. This step installs the Qt Creator integrated development environment (IDE) — it does not install Qt itself.
Step 2. Installing Qt (4.8.x)
The next step is to install Qt. Qt is the libraries and tools (e.g. qmake) that you need to build with Qt. You can install multiple versions of Qt at the same time and together with C++ compilers each version is called a kit. The easiest way to install the version of Qt that is currently required for working with the BeagleBone is to use apt-get:
molloyd@debian:~$ sudo apt-get install qt4-dev-tools
molloyd@debian:~$ qmake -v
QMake version 2.01a
Using Qt version 4.8.2 in /usr/lib/x86_64-linux-gnu
It is also possible to build Qt from source. You can do this by going to http://download.qt.io/archive/qt/ and downloading the exact version that you require.
Step 3. Configuring a Qt Creator Kit
You can then start Qt Creator as follows:
molloyd@debian:~$ cd qtcreator-3.3.81/bin/
- The Qt Creator start-up screen should present you with the option to create a new project using a button or by using File → New File or Project → Choose Application and “Qt Widgets Application”. Press “Choose”.
- Give the project a name and location (e.g., QtTest in /home/molloyd/)
- The next option is Kits (Kit Selection). It should state that “No valid kits found”. Press on options and you should see a dialog as in Figure 1 below.
- Click on the “Qt Versions” tab and click on “Add…” and browse to /usr/bin/ where you should see the qmake and qmake-qt4 entries. Click on qmake and then click Open. You should then see that a manual Qt version has appeared as in Figure 2 below.
- The compiler should have been auto-detected. If not add it by browsing to the location of gcc/mingw (e.g., /usr/bin/g++).
- Click on the “Kits” tab again and click on “Add…” Give the kit a name (e.g., Qt for Desktop) and the entries should appear as in Figure 3 below. Press OK and then a kit should appear in the dialog. Press Next. Press Next again. Press Finish.
- All going well, you can now click on the green play button on the bottom left of the IDE and the output will appear as in Figure 4.
At any stage you can return to these options using Tools → Options.