Creating Qt4 project with bitbake for Mini2440V2

This example show you how to create a Qt4 project ,and then build it with bitbake

Creating Qt4 project with bitbake for Mini2440V2
Base information:
OS: Linux
tools: bitbake openembedded qt-creator
Steps:
1. Getting Bitbake

a) dowload bitbake from: http://download.berlios.de/bitbake/bitbake-1.8.8.tar.gz
b) mkdir /home/paul/project (I make a directory named "project" under my home folder)
c) cd /home/paul/project (Go to the new folder)
b) mkdir build (Creating a new folder under project)
d) mkdir build/conf (This folder will containts the configure file)
e) touch soure-me.txt (Creating a new text file under project,it will used for initializing the enviroment)
content of soure-me.txt:

export OETREE="${PWD}"
BBPATH=${OETREE}/:${OETREE}/build/:${OETREE}/openembedded/
PKGDIR=${OETREE}/build/
echo Setting up dev env for Ångström

if [ -z ${ORG_PATH} ] ; then
ORG_PATH=${PATH}
export ORG_PATH
fi

if [ -z ${ORG_LD_LIBRARY_PATH} ] ; then
ORG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export ORG_LD_LIBRARY_PATH
fi

PATH=${OETREE}/bitbake/bin:${ORG_PATH}

cd $PKGDIR

LD_LIBRARY_PATH=
export PATH LD_LIBRARY_PATH BBPATH
export LANG=C
export BB_ENV_EXTRAWHITE="MACHINE DISTRO OETREE ANGSTROM_MODE ANGSTROMLIBC LIBC"
echo "Altered environment for OE Development"
f) tar -xzvf bitbake-1.8.8.tar.gz -C /home/paul/project (untar bitbake into project folder)
2. Getting openembedded
a) cd /home/paul/project (Go to project folder)
b) git clone git://git.openembedded.org/openembedded (dowload openembedded)
c) cp openembedded/conf/local.conf.sample build/conf/local.conf (Setting local.conf file)

3.Building qt4-embedded recipe
Because the small project needs the lib of qt4, so the first thing to do is building qt4-embedded recipe,
of cause , if you already finished this task ,you can skin this step.
Building it by command follow:
a) cd /home/paul/project (Go to the project folder)
b) source source-me.txt (initializing envira)
c) bitbake qt4-embedded (This will takes a long time)

4.Creating a small qt4 project, named " lcdslider"
a) dowload qt-creator from: http://qt.nokia.com/downloads (Please choose one fix your OS)
b) After finishing installing, open qt creator and then create a qt4 empty project.
c) Creating file named "lcdsliderWidget.h" , its content are:
#ifndef LCDSLIDERWIDGET_H
#define LCDSLIDERWIDGET_H
#include
class LCDSliderWidget : public QWidget
{
public:
LCDSliderWidget(QWidget *parent = 0);
};
#endif // LCDSLIDERWIDGET_H
d)Creating file named "lcdsliderWidget.cpp",its content are:
#include
#include
#include
#include
#include
#include
#include "lcdsliderWidget.h"
LCDSliderWidget::LCDSliderWidget(QWidget *parent)
: QWidget(parent)
{

//get the touch screen's size
int height = QDirectPainter::screenHeight();
int width = QDirectPainter::screenWidth();
//fix window's size
setFixedSize(width,height);

//quit button
QPushButton *quit = new QPushButton(tr("Quit"));
quit->setFont(QFont("Times", 18, QFont::Bold));

//LCD for showing number
QLCDNumber *lcd = new QLCDNumber(2);
lcd->setSegmentStyle(QLCDNumber::Filled);

//slider
QSlider *slider = new QSlider(Qt::Horizontal);
slider->setRange(0, 99);
slider->setValue(0);

//conneting with actions
connect(quit, SIGNAL(clicked()), QApplication::instance(), SLOT(quit()));
connect(slider, SIGNAL(valueChanged(int)),lcd, SLOT(display(int)));

//layout for parent widget
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(quit);
layout->addWidget(lcd);
layout->addWidget(slider);
setLayout(layout);
}

e)Creating file named "main.cpp", its content are:
#include
#include "lcdsliderWidget.h"

int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(images);
QApplication app(argc, argv);

LCDSliderWidget lcdslider;
lcdslider.show();

return app.exec();
}

f) Creating file named "CMakeLists.txt", its content are:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(qtTester)

SET(CMAKE_BUILD_TYPE Release)

SET(CMAKE_CXX_FLAGS "-Wall")

# QT4 Handling
FIND_PACKAGE(Qt4)

INCLUDE(${QT_USE_FILE})

SET( QTTESTER_qt4_SRC lcdsliderWidget.h )
SET( QTTESTER_qt4_UI)
SET( QTTESTER_qt4_RES images.qrc)

QT4_WRAP_CPP(QTTESTER_MOC_CPP ${QTTESTER_qt4_SRC})
QT4_WRAP_UI(QTTESTER_UI_CPP ${QTTESTER_qt4_UI})
QT4_ADD_RESOURCES(QTTESTER_RES_H ${QTTESTER_qt4_RES})

INCLUDE_DIRECTORIES( . )

# General
SET( QTTESTER_SRC
main.cpp
lcdsliderWidget.cpp
${QTTESTER_MOC_CPP}
${QTTESER_UI_CPP}
${QTTESTER_RES_H}
)

SET( QTTESTER_LIB
${QT_LIBRARIES}
)

ADD_EXECUTABLE( lcdslider ${QTTESTER_SRC} )
TARGET_LINK_LIBRARIES( lcdslider ${QTTESTER_LIB} )
INSTALL_TARGETS( /bin lcdslider)

g) OK!now,please tar this project, this name of tar will be "lcdslider.tar.gz"

5)Creating bitbake file for lcdslider project
a) cd /home/paul/project/openembedded/recipes/ (Go to bitbake file's folder)
b) mkdir lcdslider (Creating a folder for new project)
c) mkdir lcdslider/files (Creating a source folder)
d) cp whereContaintLcdslider.tar.gz/lcdslider.tar.gz lcdslider/files (copy source file)
e) touch lcdslider/lcdslider.bb (Creating a bitbake file)
f) lcdslider/lcdslider.bb's content as belowd:
DESCRIPTION = "The award winning lcd slider App, made by PAULe!"
LICENSE = "GPL"
PR = "r0"

S = "${WORKDIR}/${P}"

SRC_URI = "file://lcdslider.tar.gz"

FILES_${PN} = "${libdir}/qt4"

inherit qt4e cmake

EXTRA_OECMAKE = "-DQT_LIBRARY_DIR=${OE_QMAKE_LIBDIR_QT} \
-DQT_INSTALL_LIBS=${OE_QMAKE_LIBDIR_QT} \
-DQT_INCLUDE_DIR=${OE_QMAKE_INCDIR_QT} \
-DQT_HEADERS_DIR=${OE_QMAKE_INCDIR_QT} \
-DQT_MOC_EXECUTABLE=${OE_QMAKE_MOC} \
-DQT_UIC_EXECUTABLE=${OE_QMAKE_UIC} \
-DQT_UIC3_EXECUTABLE=${OE_QMAKE_UIC3} \
-DQT_RCC_EXECUTABLE=${OE_QMAKE_RCC} \
-DQT_QMAKE_EXECUTABLE=${OE_QMAKE_QMAKE} \
-DQT_QTCORE_INCLUDE_DIR=${OE_QMAKE_INCDIR_QT}/QtCore \
-DQT_DBUSXML2CPP_EXECUTABLE=/usr/bin/qdbusxml2cpp \
-DQT_DBUSCPP2XML_EXECUTABLE=/usr/bin/qdbuscpp2xml \
-DQT_MKSPECS_DIR=${QMAKESPEC}/../ \
"
OECMAKE_SOURCEPATH = "../lcdslider"

# Adding our bin file to the main package
FILES_${PN} = "${bindir}/*"

6)Modify file "FindQt4.cmake"
a) open this file /home/paul/project/build/angstrom.1/staging/i686-linux/usr/share/cmake-2.6/Modules/FindQt4.cmake
b) Find this line "NAMES ${QT_MODULE} ${QT_MODULE}4" and then add this "${QT_MODULE}E" at the end of this line.
Finally, it looks like "NAMES ${QT_MODULE} ${QT_MODULE}4 ${QT_MODULE}E"

7) Build lcdslider project bu bitbake
a) cd /home/paul/project/
b) source source-me.txt (initialize enviroment)
c) bitbake lcdslider
8) copy the binary file into Mini2440V2 board
a) I am very happy to see the result file named "lcdslider" under this folder :/home/paul/project/build/angstrom.1/work/armv4t-angstrom-linux-gnueabi/lcdslider-1.0-r0/lcdslider-1.0/
b) After coping this binary file into Mini2440V2 board , I just excute it by typing shell command: "lcdslider -qws", and I can operate it from hiteg's 3.5" touch screen. Have fun!