Qt Guide
This section describes the methods and procedures performed using the Qt GUI application development on MYD-AM335x, consists of two parts , the use of Qt SDK is the first part of the CD-ROM provided. General Qt application development using Qt SDK CD-ROM can be provided; second part describes how to compile Qt development environment when only Qt library the CD provided can not meet the development process need
Use Qt SDK CD-ROM supplied
- Unzip tslib to PC:
$ sudo tar xvjf /media/cdrom/05-Linux_Source/Qt_Arm/ tslib-prebuild.tar.bz2 -C /opt
- Unzip Qt SDK to PC:
$ sudo tar xvjf /media/cdrom/05-Linux_Source/Qt_Arm/qt-4.8.5-sdk.tar.bz2 -C /opt
- Configure environment variables and cross-compile Qt applications:
Please refer 1.10.4 Cross-compile Qt applications to set environment variables and cross-compile Qt applications.
Cross Compile Qt Development Environment
Please refer to chapter 1.4.2 for installing cross compiler tool and setting the environment variables.
Install “automake”, “libtool” and “autoconf” packages, compile and install “tslib”:
$ sudo apt-get install automake libtool autoconf
$ cd <WORKDIR>
$ cp /media/cdrom/05-Linux_Souce/Qt_Arm/tslib-1.4.tar.bz2 ./
$ tar –jxf tslib-1.4.tar.bz2
$ cd tslib
$ ./ts-build
$ make install
Note: If error occurs on executing “ts-build”, modify the cross compiler tool path in “ts-build” file.
After compilation, “tslib” will be installed under directory “/usr/local/tslib”. Replace the text "# module_raw input" in the second line of “tslib/etc/ts.conf” under current directory with "module_raw input". Be sure that it must be top grid as shown in next Figure:
Figure 1-7
- Build Qt
Copy Qt source code to the working directory:
$ cd <WORKDIR>
$ cp /media/cdrom/05-Linux_Source/Qt_Arm/\
qt-everywhere-opensource-src-4.8.5.tar.bz2\ ./
Install necessary toolkits:
$ sudo apt-get install xorg-dev libfontconfig1-dev
libfreetype6-dev libx11-dev libxcursor-dev libxext-dev
libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev
Begin to Compile:
$ tar -jxf qt-everywhere-opensource-src-4.8.5.tar.bz2
$ cd qt-everywhere-opensource-src-4.8.5
$ ./qt-build
$ sudo make install
After compilation, qt-4.8.5 will be installed to directory “/opt/qt-4.8.5”.
Transplant Qt to the Development Board
- Copy the “tslib” installation files in “/usr/local/tslib” to directory “myd-am335x_rootfs /usr/local/ tslib”, which is used to compile the file system.
$ cp –r /usr/local/tslib/bin \
<WORKDIR>/myd-am335x_rootfs/usr/local/ tslib
$ cp –r /usr/local/tslib/etc \
<WORKDIR>/myd-am335x_rootfs/usr/local/ tslib
$ cp –r /usr/local/tslib/lib \
<WORKDIR>/myd-am335x_rootfs/usr/local/ tslib
- Copy qt-4.8.5 installation files in directory “/opt/qt-4.7.1” to “myd-am335x_rootfs /opt”:
$ cp -r /opt/qt-4.8.5 <WORKDIR>/myd-am335x_rootfs/opt/
- Enter directory “/etc/init.d”, edit the script “qt.sh” as follows:
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CONFFILE=/usr/local/tslib/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/tslib/lib:/opt/qt-4.8.5/lib
export QT_QWS_FONTDIR=/opt/qt-4.8.5/lib/fonts
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/usr/local/tslib/bin
if grep "hdmi" /proc/cmdline > /dev/null ; then
export QWS_MOUSE_PROTO="Tslib:/dev/input/event1 MouseMan:/dev/input/mice"
else
export QWS_MOUSE_PROTO="Tslib:/dev/input/event1"
fi
export QWS_DISPLAY=:1
Export QWS_DISPLAY=:1Modify the “rc” file under directory “/etc/init.d/”of develop ment, add the following contents at the end of the document:
if [ -e /etc/init.d/qt.sh ];then
/etc/init.d/qt.sh
fi
- Recompile the file system, then a “ubi.img” file containing the Qt libraries and “tslib” will be generated.
Cross-compile Qt applications
- Configure the Qt environment:
$ export QT_PREFIX=/opt/qt-4.8.5
$ export PATH=${QT_PREFIX}/bin:$PATH
$ export QMAKESPEC=${QT_PREFIX}/mkspecs/qws/linux-arm-g++
- Creating a code:
$ mkdir hellomyir
$ cd hellomyir
$ gedit hellomyir.cpp
Enter the following code:
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv)
{
QApplication app(argc,argv);
QLabel label("Make Your idea Real!");
label.show();
return app.exec();
}
- Build:
$ qmake -project
$ qmake
$ make
- Copy the “hellomyir” to development board, and run it:
#./hellomyir
A text will see on the LCD screen is "Make Your idea Real!".