Showing posts with label Qt. Show all posts
Showing posts with label Qt. Show all posts

2011-01-04

A script for build Qt application for board arm-

A script build-armsys-6410.sh to build the Qt application for board armsys6410.
  • Cross-compiler is located at /usr/local/arm/4.2.2-eabi/usr/bin
  • Built Qt by the cross-compiler is installed at  /usr/local/qt-4.7.1-armsys-6410/bin/qmake
  • Built Tslib by the cross-compiler is installed at /usr/local/tslib/lib


export PATH=/usr/local/arm/4.2.2-eabi/usr/bin:$PATH
make clean
/usr/local/qt-4.7.1-armsys-6410/bin/qmake LIBS+=-L/usr/local/tslib/lib\ -lts
make

Fullscreen of Qt Application

See the nice tutorial at Meego
http://wiki.meego.com/QML/Full-screen_applications

2011-01-01

tslib Error & Solution

Task: Build Qt 4.7.1 for board armsys-6410.

Toolchain: supplier provided toolchain (4.2.2-eabi-arm)

Error: When start a Qt example, the following error message show

QWSTslibMouseHandlerPrivate: ts_config() failed with error: 'No such file or directory'
Please check your tslib installation!

The problem is solved by following:

Download & build the latest tslib again from http://tslib.berlios.de/


> tar xzvf tslib-1.4.gz
> cd tslib
>./autogen.sh
>./configure -host=arm-linux -prefix=/usr/local/tslib
>make
>make install
Qt was successfully build with the toolchain:
./configure -prefix /usr/local/qt-4.7.1-armsys-6410 -embedded arm -xplatform qws/linux-arm-g++ -depths 16 -qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib -R /usr/local/tslib/lib -xmlpatterns -exceptions
make
make install
Copy the installed Qt into root file system, which will be nfs mounted by board
sudo cp -rf /usr/local/qt-4.7.1-armsys-6410 /home/max/work/arena/rootf/armsys6410/root/usr/local/
Start the board by nfs mounting  /home/max/work/arena/rootf/armsys6410/root/
I use minicom here, the parameters are
setenv bootargs "root=/dev/nfs nfsroot=192.168.2.118:/home/max/work/arena/rootf/armsys6410/root/ ip=192.168.2.10:192.168.2.118:192.168.2.1:255.255.255.0:armsys.hzlitai.com:eth0:off console=ttySAC0,115200" 
Check the device file of touchscreen. Assume the device of board is /dev/input/event1
cat /dev/input/event1| hexdump
Now when you move the mouse in the touchscreen, the similar texts will be displayed on the console. It means that /dev/input/event1 is the correct device file of touchscreen on board.

...
0000300 7cc6 3a50 bb73 000b 0003 0001 1f94 0000                                
0000310 7cc6 3a50 bb7d 000b 0000 0000 0000 0000                                
0000320 7cc6 3a50 cee6 000b 0003 0000 0fbb 0000                                
0000330 7cc6 3a50 cefa 000b 0003 0001 1fff 0000                                
0000340 7cc6 3a50 cf03 000b 0000 0000 0000 0000                                
0000350 7cc6 3a50 e269 000b 0001 014a 0000 0000                                
0000360 7cc6 3a50 e27c 000b 0003 0018 0000 0000                                
0000370 7cc6 3a50 e281 000b 0000 0000 0000 0000
....

Add following enviromental variables into /etc/profile

export TSLIB_ROOT=/usr/local/tslib
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export TSTS_INFO_FILE=/sys/devices/virtual/input/input0/uevent
export QWS_MOUSE_PROTO=tslib:/dev/input/event1
export QWS_KEYBOARD=TTY:/dev/tty1
export HOME=/root
export QTDIR=/usr/local/qt-4.7.1-armsys-6410
export QPEDIR=/usr/local/qt-4.7.1-armsys-6410
export PATH=$PATH:/usr/local/tslib/lib:$QTDIR/bin
export LD_LIBRARY_PATH=$QTDIR/lib:/usr/local/tslib/lib:/usr/local/lib:$LD_LIBRARY_PATH






Run calibration again.
/usr/local/tslib/bin/ts_calibrate
Try a Qt example,
/usr/local/qt-4.7.1-armsys-6410/examples/widgets/calculator/calculator -qws

The error messages didn't show again.

References

Nice man doc of tslib
http://www.blogger.com/post-edit.g?blogID=5974839100591333846&postID=6336916594199395808

About QWS_MOUSE_PROTO
http://doc.qt.nokia.com/4.7-snapshot/qt-embedded-pointer.html

homepage of tslib
http://tslib.berlios.de/

minicom nfs copy kernel to board
http://www.armsystem.com.cn/bbs/redirect.php?fid=29&tid=12260&goto=nextnewset

http://www.qtcentre.org/threads/23353-Qt-Embedded-4.5-TsLib-and-TSC-10-touch-screen-(Solved)

2010-12-27

Build Qt 4.7 for armsys-6410

=======================
Install the crossing toolchain
=======================
refer to chapter 4 安装交叉编译器

交叉编译工具链的安装文件为“ARMSYS6410-B基础配置光盘资料\Linux相关\linux2.6标准版\交叉编译器”目录下的 cross-4.2.2-eabi.tar.bz2.

>tar xjvf cross-4.2.2-eabi.tar.bz2 –C /usr/local/arm
>export PATH=$PATH:/opt/toolchains/arm920t-eabi/bin

=======================
Build tslib (touch screen)
=======================

Install necessary tools
> apt-get install autoconf automake libtool

Download souce of tslib from http://tslib.berlios.de/


Build tslib
> tar xzvf tslib-1.4.gz
> cd tslib
>./autogen.sh
>./configure -host=arm-linux -prefix=/usr/local/tslib -enable-input=no (wrong???)
tslib will be install at /usr/local/tslib. If get error, you may comment out the line " '#define malloc rpl_malloc" in config.h
>make
>make install
Reference: http://blog.chinaunix.net/u2/75270/showart_1793535.html

=======================
Build Qt 4.7.1
=======================

Download qt-4.7.1
>wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.1.tar.gz
>tar xfzv qt-everywhere-opensource-src-4.7.tar

Configure the Qt Embedded.
>./configure -prefix /usr/local/qt-4.7.1-armsys-6410 -embedded arm -xplatform qws/linux-arm-g++ -depths 16 -qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib -R /usr/local/tslib/lib -xmlpatterns -exceptions

Build Qt
>make
>make install
Reference: http://doc.qt.nokia.com/main-snapshot/qt-embedded-crosscompiling.html

2010-06-18

Build Qt with support of png, jpeg, tiff

Strongly recommanded to build Qt with his own library of png, jpeg, tiff by
./configure -qt-libtiff -qt-libpng -qt-libjpeg


Actually, these options are not default (marked with +). See "configure Options (Qt)": 


        -no-zlib ........... Do not compile in ZLIB support. Implies -no-libpng.
        -qt-zlib ........... Use the zlib bundled with Qt.
     +  -system-zlib ....... Use zlib from the operating system.
                             See http://www.gzip.org/zlib

        -no-gif ............ Do not compile the plugin for GIF reading support.
     *  -qt-gif ............ Compile the plugin for GIF reading support.
                             See also src/plugins/imageformats/gif/qgifhandler.h

        -no-libtiff ........ Do not compile the plugin for TIFF support.
        -qt-libtiff ........ Use the libtiff bundled with Qt.
     +  -system-libtiff .... Use libtiff from the operating system.
                             See http://www.libtiff.org

        -no-libpng ......... Do not compile in PNG support.
        -qt-libpng ......... Use the libpng bundled with Qt.
     +  -system-libpng ..... Use libpng from the operating system.
                             See http://www.libpng.org/pub/png

        -no-libmng ......... Do not compile the plugin for MNG support.
        -qt-libmng ......... Use the libmng bundled with Qt.
     +  -system-libmng ..... Use libmng from the operating system.
                             See http://www.libmng.com

        -no-libjpeg ........ Do not compile the plugin for JPEG support.
        -qt-libjpeg ........ Use the libjpeg bundled with Qt.
     +  -system-libjpeg .... Use libjpeg from the operating system.
                             See http://www.ijg.org

        -no-openssl ........ Do not compile support for OpenSSL.
     +  -openssl ........... Use OpenSSL from the operating system.

If Qt is not built with these options. sometime images cannot be correctly displayed. See this QTBUG-11453.

2010-05-24

Error "cannot find -lXrender" at Build of QT

Reason: missing package of libxrender-dev.
>sudo apt-get update
>sudo apt-get install libxrender-dev

2010-05-14

QWidget vs QML

"QWidgets are a better choice if your UI is comprised of a small number of complex and static elements, and QML is a better choice if your UI is comprised of a large number of simple and dynamic elements."
Reference:

2010-05-06

Qt 4.7 and Qt Creator 2.0

The first try of Qt Creator 2.0 + Qt 4.7, both of them are in beta phase.
  1. Download them from http://qt.nokia.com/developer/qt-qtcreator-prerelease#download.
  2. Installation
  3. Configuration. Tools->Options->Qt4->Manual.Give correct path of qmake and mingw. e.g. qmake location: c:\qt\4.7.0-beta1\bin\qmake.exe; MinGW directory: c:\Qt\qtcreator-1.3.83\mingw\
  4. Import qml demo. See the video

2010-05-02

Link error during build Qt 4.6.2

Max encounter the following link error, as he tried to build Qt 4.6.2 with a angstrom toolchain for mini2440 ARM9 board:

/usr/bin/ld: .obj/release-shared/harfbuzz-buffer.o: Relocations in generic ELF (EM: 40)
.obj/release-shared/harfbuzz-buffer.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status

After a short analysis, he found out that it supports to be the problem of crossing compiler toolchain.

>ls -al /usr/bin/gcc
lrwxrwxrwx 1 root root 63 2009-10-27 20:35 /usr/bin/gcc -> /usr/bin/gcc-4.1
Here is quick solution, but there may exists better solution.
>rm /usr/bin/gcc
>ln -s /opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/bin/gcc /usr/bin/gcc
The reconfigure and build everything
>make confclean
>./configure -embedded arm -xplatform qws/linux-arm-g++ -depths 16 -qt-mouse-tslib
>make
>make install

2010-04-28

Qt Creator 1.3 doesn't Support Embedded Device Development

Does Qt Creator support embedded/mobile software development?

Answer:
For this initial launch, we focused on ensuring that Qt Creator supports desktop development. However, following the Qt Everywhere strategy, we plan to provide the functionality necessary for embedded/mobile software development. This functionality includes remote compilation and debugging tools as well as device deployment solutions. Our aim is to provide this functionality later in 2009.

Reference:
http://qt.nokia.com/developer/faqs/does-qt-creator-support-embedded-mobile-software-development?hotspoturl=http%3A//qt.nokia.com/developer/faqs

2010-04-07

OpenCL in Qt

"...For those new to it, OpenCL is an open, royalty-free standard for parallel programming in a heterogeneous computing environment. The most common use you’ve probably heard of is to run arbitrary C code on your system’s GPU..."


"... It defines a new C-style language that is more precise as to mathematical precision, and which allows arbitrary arguments to be provided to an OpenCL function - known as a kernel - to do almost anything that C can do. Special vector types like “float4″ are provided as well as an extensive mathematical library.  But its most impressive feature is work sizes - it is very easy to split your task up into small chunks that the GPU can scatter across all of its compute units (compute units include whatever CPUs and GPUs OpenCL can find, OpenCL uses everything available).  Unlike regular C where you can spend a lot of time writing outer loops and launching worker threads for subparts of your problem, OpenCL does it for you. We’ll see how that works shortly..."


Reference:

2010-04-06

Use XQuery

XQuery allows programmer to save the xml-query (or filter) into a seperated Python-like file, e.g
for $time in doc("forecast.xml")//tabular/time
      return <time>
          { $time/@from }
          <temperature>
              { $time/temperature/@value, $time/temperature/@unit }
          </temperature>
             </time>

A nice artical demonstrating the usage of XQuery is published in Qt Quaterly: Checking the Weather with XQuery(http://qt.nokia.com/developer/qtquarterly/checking-the-weather-with-xquery)

Reference:

2010-02-17

Build Qt as Static Library

Your Qt applications could be smaller and most importantly can be distributed as a single executable, if it is statically linked with Qt library.

A static built Qt application is faster. According to the artical "Qt Performance Tuning":

"A lot of CPU and memory is used by the ELF (Executable and Linking Format) linking process. Significant savings can be achieved by using a static build of the application suite; rather than having a collection of executables which link dynamically to Qt's libraries, all the applications is built into into a single executable which is statically linked to Qt's libraries."

First of all, you need to build Qt as a static library. See the thread http://lists.trolltech.com/qt-interest/2003-05/thread00396-0.html
./configure -thread -static  (makes libqt-mt.a)
./configure -static (makes libqt.a)
./configure (makes libqt.so)
./configure -thread (makes lib-mt.so)
Then, add the necessary plugins. See the artical http://doc.trolltech.com/4.6/plugins-howto.html#static-plugins.

Finally, deploy your application. See the artical http://doc.trolltech.com/4.6/deployment.html.

References:

2010-02-03

Build Qt State Machine Framework as a Static Library

If qt state machine package is by default built as dynamical library, the steps below shows how to build its static version.
  • >wget ftp://ftp.trolltech.com/qt/solutions/lgpl/qtstatemachine-1.1-opensource.tar.gz
  • >tar xvfz qtstatemachine-1.1-opensource.tar.gz
  • >edit buildlib/buildlib.pro change CONFIG += dll to CONFIG +=staticlib
  • >qmake qtstatemachine.pro
  • >make
  • static library is build at lib/libQtSolutions_StateMachineFramework-1.1.a.

2010-01-28

Z Value of GraphicsItem

Z value of each QGraphicsItem determines its stacking order of visibility in parent items.
It can be explicitly specified by setZValue( qrea z ) . Otherwise, it is decided by the order of being assigned to its parent through these two functions:
  • QGraphicsItem::setParentItem ( QGraphicsItem * parent )
  • QGraphicsItemGroup::addToGroup ( QGraphicsItem * item )

2010-01-27

Qt update its examples pages

Looks much better.
http://qt.nokia.com/doc/4.6/examples.html

Q_PROPERTY example

class CLLcd : public QLCDNumber
{
Q_OBJECT
Q_PROPERTY( bool editable READ editable WRITE setEditable )
public:
bool editable(){return editable_; }
void setEditable(bool editable_in){editable_=editable_in;}
private:
bool editable_;
}

2010-01-22

Make LCDNumber Transparent



MyClockLcd::MyClockLcd ( QWidget *parent )
:QLCDNumber(parent)
{
//show decimal
setMode( Dec );

//segment style
setSegmentStyle( Filled );

// transparent background
setAttribute( Qt::WA_NoBackground );

//no frame
setFrameStyle( QFrame::NoFrame );
display("00:00");

}

2010-01-21

Foreach in Qt Container

Great! Qt container supports foreach iteration, which simplies largely the code. See the example for comparison:


========= java-like iterator===============
QLinkedList<> list;
...
QLinkedListIterator<> i(list);
while (i.hasNext())
qDebug()<< i.next()

========== STL-like iterator=============
QLinkedList<> list;
...
QListedList<>::const_iterator it = list.begin();
while( it!= list.end())
{
qDebug()<< (*it); ++it; }

=========foreach iteration===============

QLinkedList<>> list;
...
foreach (QString str, list)
qDebug() << str

===================================

Reference:

2010-01-20

Debug Qt Application with gdb

If the Qt application is built in Linux system (Max uses Debian Lenny), you need to just run
  • > gdb app
See the thread http://jingfenghanmax.blogspot.com/2010/01/useful-gdb-commands.html

However, you need to add debug option into makefile by add line into *.pro file
  • CONFIG += config qt
Note: "+=" instead of "=", otherwise, the application may have problem when it tries to load the resource files defined in qrc file.