Guide

The Qt library has the ability to render graphics directly on a Linux framebuffer without the need for X11 or any other windowing system. Qt provides its own windowing library known as QWS. This variant is called Qt/Embedded but we will call it Qt/QWS to be more clear.

The Qt/X11 libraries and the Qt/QWS libraries are API compatible (with the exception of some X11 specific functions) but unfortunately they are not ABI compatible. For this reason, a prefix is added to the Qt/QWS SONAME to distinguish between the two variants (eg libQtGuiQWS.so.4 vs libQtGui.so.4).

Installing Qt/QWS

Precompiled Ubuntu packages of Qt/QWS are available at:

You can add a PPA to you system by running:

$ sudo apt-add-repository ppa:asac/armel1

or

$ sudo apt-add-repository ppa:afrantzis/qt4-qws

and then:

$ sudo apt-get update
$ sudo apt-get install libqt4-qws-dev qt4-qws-demos

The libqt4-qws-dev package will pull in with it all available Qt/QWS components.

Note that libqt4-qws-dev conflicts with libqt4-dev (the Qt/X11 variant) for the time being because (among other things) both packages contain pkg-config files with the the same name (eg QtGui4.pc). This was done on purpose to make it easy and transparent to compile applications against Qt/QWS instead of Qt/X11.

Alternatively you can build and install Qt/QWS by following the instructions in:

http://doc.qt.nokia.com/4.7-snapshot/qt-embedded-install.html

Running Qt/QWS applications under X11 (using QVFB)

The Qt/X11 build contains a virtual frame buffer that can be used to run Qt/QWS programs under X11. To get it:

$ sudo apt-get install qt4-dev-tools
$ qvfb

This will create a virtual framebuffer inside a normal X11 window to which QWS programs can draw in. You change the size of the framebuffer in File->Configure. (the default size is too small to play around).

Now let's start a sample program (included in the qt4-qws-demos package):

$ export QT_QWS_FONTDIR=/usr/share/fonts/truetype/ttf-dejavu
$ /usr/lib/qt4-qws/demos/mainwindow/mainwindow -qws

The first command tells Qt/QWS where to find font files to use. The second command runs the program and also tells it to act as QWS server. There can be exactly one QWS server active at time.

You should now see the application running normally in the framebuffer. You can do almost everything except minimize the window.

To start more QWS applications run them without the -qws flag:

$ export QT_QWS_FONTDIR=/usr/share/fonts/truetype/ttf-dejavu
$ /usr/lib/qt4-qws/demos/spreadsheet/spreadsheet

Running Qt/QWS applications under Linux FB

You can run applications under Linux FB almost as easily as under X11. The only difference is that you have to set up the keyboard and mouse inputs and the framebuffer device.

Setting up the framebuffer device

Make sure that the framebuffer device (usually /dev/fb0) is readable and writable by you. For example you can do:

$ sudo chmod 666 /dev/fb0

Setting up keyboard input

Make sure the terminal device you are running in (eg /dev/tty0) is readable and writable by you. For example you can do:

$ sudo chmod 666 /dev/tty0

Setting up mouse input

First you must find out which device corresponds to your mouse. To do that try to see which device outputs data when you are moving the mouse around (while you are in a framebuffer terminal):

$ cat /dev/input/mouse0 | hexdump

After you have found the device, make sure it readable and writable by you:

$ sudo chmod 666 /dev/input/mouse0

and also set the QWS_MOUSE_PROTO environment variable to let QWS know where to read from:

$ export QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse0

Running the application

First, make sure the QWS_MOUSE_PROTO and QT_QWS_FONTDIR environment variables are set as described above:

$ export QT_QWS_FONTDIR=/usr/share/fonts/truetype/ttf-dejavu
$ export QWS_MOUSE_PROTO=IntelliMouse:/dev/input/mouse0

then run:

$ /usr/lib/qt4-qws/demos/mainwindow/mainwindow -qws

As in the QVFB case, you can run more applications by omitting the -qws flag for them.

Building applications using Qt/QWS

To build applications using Qt/QWS you need to have libqt4-qws-dev and qt4-qws-qmake installed.

If the application you are trying to build is based on qmake project files then just use qmake-qt4-qws to produce the Makefile from the qmake .pro project file. Alternatively, you can use update-alternatives and make "qmake-qt4-qws" the default alternative for "qmake", so you can just use qmake.

If the application uses pkg-config then it should Just Work (TM) because as mentioned in the beginning the .pc files shipped with libqt4-qws-dev have the same name as the Qt/X11 ones (that is why the libqt4-qws-dev and libqt4-dev packages conflict). If you need to build applications for Qt/X11 just reinstall the libqt4-dev package.

Specs/M/ARMQtonEmbedded/Guide (last edited 2010-06-25 08:28:37 by 77)