Work - a Qt platform

I'm feeling like a lucky guy - getting to work with Qt on a day-to-day basis. A couple of days back, BitSim, my employer announced a Qt-based embedded hardware platform. Highlights are PXA270, a Spartan FPGA and a radio module. Right now I'm waiting for our demo pair to arrive, so that I can create some sort of demo utilizing the two units and the radio.

Well, now I'm off to work again. Shell scripting this time...



Embedded Qt

I'm doing a series of 2h seminars on Qt for Embedded Linux these days. If you are interested and located somewhere in Scandinavia or near-by, drop a mail to e8johan -at- gmail.com.



LGPL'ed solutions

I saw that Tro^H^H^HQt Software - let's just call them the trolls - have released a bunch of QtSolutions under the LGPL license. Nice! There are quite a few solutions still available, check out the list. When listing a bunch of widget add-ons, I have to mention the wwWidgets as well.



Lesson learned

Just learned that the window flags Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint isn't enough in X11 (seems to work on WinXP). You also need to add the Qt::Tool window flag. Just so that you know.



Missing Person?

I've tried to contact a Johannes Bergmeier, working with the Orchid Web-Framework. Kindly check your spam filter and/or contact me at e8johan. I use gmail.



Environmentally Friendly

Continued from here.

The Qt painting system uses four quite interesting environment variables: QT_FLUSH_PAINT, QT_FLUSH_PAINT_EVENT, QT_FLUSH_UPDATE and QT_FLUSH_WINDOWSURFACE. The purpose of each of these four is to initialize painting surfaces with a yellow colour before painting. See Aaron's blog on this for an example.

The input method module, qmultiinputcontext.cpp, uses the QT_IM_MODULE and QT4_IM_MODULE variables to pick an appropriate module.

If you have a debug version of Qt, QT_LAYOUT_DEBUG adds additional warning messages indicating if you place your widgets in strange layouts (wrong parent or layout).

If you want to skip Qt's double buffering (the backing store) you can use the QT_ONSCREEN_PAINT variable to force all the painting to be made directly to the screen.

The QT_PLUGIN_PATH environment variable can be used to control where Qt looks for plugins.

environment variable, you can make the Plastique style not use the QPixmapCache.

The WebKit module listens to the QT_WEBKIT_LOG and QTWEBKIT_PLUGIN_PATH variables. These two control which logging channels to use and where to look for plugins.

This concludes this afternoons grepping. I will continue with TMPDIR before reaching the Qt for Embedded Linux source.



It is all about the environment

I've just downloaded Qt 4.5 beta 1 and started playing with it. One thing that I've run into a couple of times now are environment variables. Their usage is quite sparsely documented, and can really prove to be useful. So, to have an excuse to look around in the source, I greped a bit.

grep getenv -r src/ | grep cpp\: | grep -o "\"[A-Z_0-9]*\"" | sed 's/"//g'

The X11 version gives 83 hits, while Qt for Embedded Linux (tp1) gives 101. Mergin the two gives 108 unique strings. The difference between these two is fun to look at, but lets start with the more commonly used version: X11.

The variables BROWSER and DEFAULT_BROWSER are used from the QDesktopServices class. The XDG_CACHE_HOME, XDG_CONFIG_HOME and XDG_DATA_HOME are also used by the same class. These variables are all specified in the XDG Base Directory Specification from freedesktop.

QApplication uses a number of environment variables. First, a whole range of variables regarding sessions and desktop ids: DESKTOP_SESSION, DESKTOP_STARTUP_ID, GNOME_DESKTOP_SESSION_ID and SESSION_MANAGER. Then, there is the KDEHOME directory.

There are a number of tuning variables that affect the QApplication class. I have not over analyzed the following, so correct my explanations if I'm wrong.
  • QT_NO_GLIB - prevents Qt from using GLib's event loop.
  • QT_SLOW_TOPLEVEL_RESIZE - used to solve KDE bug #157659.
  • QT_USE_NATIVE_WINDOWS - makes Qt flicker :-)
  • QT_X11_NO_FONTCONFIG - makes Qt not to use X11's FontConfig.
  • QT_X11_NO_MITSHM - stops Qt form using the MIT-SHM X11 extension.
  • QT_X11_NO_XRENDER - prevents Qt from using the Xrender extension.
The QSslSocket class uses DYLD_LIBRARY_PATH and LD_LIBRARY_PATH through qsslsocket_openssl_symbols.cpp.

GTK2_RC_FILES is used to find GTK symbols when styling. KDEDIRS and KDE_SESSION_VERSION are also used by the style classes.

HOME is used from the classes QFSFileEngine and QPrintDialog.

Phonon uses a whole bunch of environment variables. I will not dive deeper into these, at least not for now.
The LANG variable is used by QLocale as expected, but also by QTextCodec and QIconvCodec. The variables prefixed with LC_ are also used by the same classes.
  • LC_ALL (QLocale, QIconvCodec, QTextCodec)
  • LC_CTYPE (QIconvCodec, QTextCodec)
  • LC_NUMERIC (QLocale)
The Qt 3 support version of QFileDialog uses LOGNAME when trying to determine the location of ~.

LPDEST is used by QPdf and QPrinterInfo. The same classes also use the NGPRINTER, NPRINTER and PRINTER variables.

MALLOCSTATS is ued by the webkit JavaScriptCore component. Continuing in the webkit sources, the WebCore component uses MOZILLA_HOME, MOZ_PLUGIN_PATH, QT_WEBKIT_LOG and QTWEBKIT_PLUGIN_PATH.

One of the most popular environment variables, PATH, is used by FreeType, libtiff, QProcess, QCoreApplication as well as Q3Process.

QDBUS_DEBUG can be used to turn on d-bus debugging.

The QT4_IM_MODULE variable controls the input method to use.

QT_ACCESSIBILITY makes it possible to turn of accessibility (just set it to a non-one value).

By setting QT_CRASH_OUTPUT to a file name, a backtrace is written there when a signal is encountered.

Set QT_DEBUG_PLUGINS to a non-zero value to enable debugging of Qt plug-ins.

The QTestLib module uses a number of variables:
  • QTEST_COLORED - controlls if the output should be coloured or not.
  • QTEST_EVENT_DELAY - delays events.
  • QTEST_KEYEVENT_DELAY - delays key events.
  • QTEST_KEYEVENT_VERBOSE - verbose output for keyboard events.
  • QTEST_MOUSEEVENT_DELAY - delays mouse events.
To make Qt exit on warnings, set QT_FATAL_WARNINGS.

Now I'm about half-way through my list and, as all of you knows, time flies when you're having fun. Next time, I'll resume at QT_FLUSH_PAINT!



Winners of the Qt Centre Programming Contest 2008

Being late seems to have become a tradition - let's hope that we do better next time. At last the winners have been properly announced, together with their respective prizes at QtCentre.org.



My fault

Open source and free software can be hard some times. Time constrains and priorities sometimes collide and people get disappointed and annoied.

I'm writing to tell everyone that I'm sorry. The QtCentre programming contest has been finished since a while back. The judges have been great, and the prizes are assigned to the winners. What is missing is the "press material" from me announcing this.

The reason for not having done this on time (which was about two weeks ago) are threefold:
  • Customer events at my work (due tonight, I'm speaking on Qt).
  • Deadline at my customer (due on Friday, i.e. overtime every day since last Thursday)
  • 7 months old daughter that I really want to see, at least on weekends as I leave for work before she gets up and see her fall asleep at night.
I know my failure to deliver means that people get upset. The judges who are done since a while back and get lots of badwill from this. The contestants not getting the final results and our sponsors, seeing a negative spin around the final stages of the contest.

As this week will continue to be hellish for me, I can only promiss to get this done during this Saturday. I hope that this will be quick enough and that you all can accept my appologies. If not, don't nag the other guys - it is my fault.



Qt Centre Programming Contest 2008 - Finalists

So, the judging process has finally reached its first milestone - six finalists have been chosen. Those of you who visited FSCONS on Friday know them - to the rest of the world - the announcement is up now (yes - I know - lateish).

So, here they are, in no particular order, the finalists of this years contest:


“A simple, yet complete and easy to use application for downloading Flash movies from YouTube and similar sites and for converting them to other, more usable formats. It uses ffmpeg to do the conversion.”


“Allows users to write AJAX-enabled web applications in C++. It features built-in HTTP server and the application code looks almost
like Qt app.”


“An attractive alternative menu implementation for KDE 4 with clickless interface. You can drag the icon list to your desktop.”

WebIssues Client

“Qt-based client for an issue tracker written in PHP. Nice looking, complete and documented.”


“Frees the signal and slot mechanism from both the process and the actual computer. This opens a range of possibilities for Qt applications.”


“An plugin based communications application. Allows rich media sharing with a beautiful user interface.”

On behalf of everyone working hard at QtCentre I'd like to say thank you to all the contestants, all the judges, our great sponsors and everybody using the site. Thank you!



München DevDays'08

I've been wanting to blog something about DevDays, but I'm still sitting here, working. Anyway, I visited Munich and DevDays this week. A great event. Lots of people (600-ish), great talks and good beer.

DevDays seems to be the day when the QtCentre admins and moderators meet. This year Witold, Jacek, J-P, Kevin and I where there. Kevin actually visited with some silly KDE badge instead of the proper QtCentre one :-)

For me, the highlights where really Ariya's talk on Blazing Fast Graphics (he used ray-casting - those where the days!) and Jurgen's talk on Embedded Qt (nice to see that my customer projects fitted his template project quite nicely). Also nice where the keynotes - good to see that Nokia still wants Qt to be available everywhere.

We from QtCentre tried to fit people into our t-shirts. The snapshot below shows Justin from ICS. I also passed a t-shirt onto Benoit Schillings but I did not see him wear it. If you read this, Benoit, please mail me a photo of you wearing it or blog about it on labs.



Fifteen Minutes of Fame

As I'm speaking at FSCONS'08 I got interviewed by hesa.



Model-View Seminar

ICS Network just released a webcast featuring - tada - me, speaking about Qt's Model-View framework. You can watch it over at the ICS Network site. Questions, comments and other discussions are help over at QtCentre's forum thread.



New Article

I don't know for how long it has been available on-line, but I wrote another article for Qt Quarterly. For your reading pleasure: Designing Delegates.



Building Qt on a clean Kubuntu

I have to admit it - I always build my own Qt. Because of customers sticking to older versions and myself wanting to have the latest, I currently have 4 flavors of Qt and 3 of QtopiaCore sitting on my laptop.

As I recently invested in a new computer I felt that I had to build Qt + Qtopia on it. The computer was installed with a clean Kubuntu from the start. The problem is that Qt requires some packages to build and finding those packages is (at least for me) a tedious iterative process (make - look what failed - apt-get install it - repeat). So, without further ado, here is a list of packages that you need to get 4.3.4 X11 to build properly:
  • build-essential
  • libx11-dev
  • libxext-dev
So, make sure to apt-get install those before running ./configure && make && make install && echo -e "\a" . At least it keeps you from interrupting your I'm-compiling-thus-working-coffee-break. :-)

Sidenote: I guess Qt 4.4 requires some gstreamer goodies as well, I'll tell you when I get there.



Commercial Qt on Vista using MinGW

Since I just got my new computer up and running, I wanted to start using Qt. Another new, for me, is Vista, so I decided to get my commercial Qt license up and running using MinGW in Vista. The proved to be a small challenge so I've documented my steps here.

First of all, put your license file in your user directory and try to rename it to .qt-license. Notice that the file explorer won't let you do that. Apparently the only dot denotes the start of the file ending, so in Vista's eyes, a file starting with a dot has no name. The solution is, as always, to use a command prompt and good old ren.

I've downloaded MinGW and the commercial Qt sources for win32. These are installed/extracted into the Coding directory located in my home directory (being C:\Users\Thelin in my case). MinGW lives in Coding\MinGW while Qt is in Coding\qt-win-commercial-src-4.4.1.


Let's continue by using a command prompt and set some environment variables to point out these facts. We need to include MinGW in the PATH variable. Then Qt needs the QTDIR and QMAKESPEC variables to get its foothold.
set PATH=%PATH%;C:\Users\Thelin\Coding\MinGW\bin

set QTDIR=C:\Users\Thelin\Coding\qt-win-commercial-src-4.4.1

set QMAKESPEC=%QTDIR%\mkspecs\win32-g++
As we are used to from Unix, we then configure Qt before building it. This is straight forward, but I've included my configure line for completeness.

configure.exe -debug-and-release -shared -plugin-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -no-libtiff -no-gif -no-dsp -no-vcproj -assistant-webkit
The last step of the configuring is the construction of QMake for your configuration. It is good to know that the file pbuilder_pbx.cpp takes ages to build (see TaskTracker #162299). Apparently by design.

When QMake has been built, simply do as told. Run mingw32-make to build Qt. I choose to add the argument -j4 to utilize my CPU cores better. Don't know if it improves the build time much but it makes me feel good.

Now, all that is left is to add %QTDIR%/bin to PATH and to try the Qt demos. However, keep on reading if you want to make the installation easier to use.

set PATH=%PATH%;%QTDIR%\bin
Command Line Conveniences

To make it a bit easier to get up and running with Qt, we will create two batch files. First, qt-vars.bat, that initializes the environment variables as shown in this text (gather all the lines starting with set in a file). To make things fancy, you can create a short-cut to this file. Set it to run cmd /K qt-vars.bat to end up with an intialized command prompt - quite nice.

The second batch file that I mentioned before is make.bat. Make it run mingw32-make and place it somewhere in path. If you want to be able to use command line arguments, pass on a few %1 %2 %3 and so on to MinGW. This will allow you to type make -j4, instead of prefixing it with mingw32- every time. You can place this file either in Qt's bin directory, or with the MinGW executables.


Since the Windows command prompt leaves quite alot to wish for, I prefer trying something else for a change. It it possible to use cygwin or other shell replacements, but hey, we're in a graphica environment, so why no try to use something grapical such as Eclipse.

Qt integrates quite well with Eclipse. Start by downloading Eclipse for C/C++, or just the standard edition with and the C/C++ support module. Then download the Qt integration. Commercial license holders will find it in their personal download directory.

Once all the installers have been run, start Eclipse through the Qt Eclipse Integration item on the Windows start menu. Then select File - New - Project... and choose to create Qt application. This will prompt you to specify what Qt version to use in the dialog shown below. Simply point out the version you just built and you are ready to go.

The Qt integration works great - but sometimes you can get a feeling of nausea. For example, it is not clear from the start how to execute the result of your project. But, then you can always revert to the good old command line.



It has a GUI

In the past, I fiddled with fractals. To force my-self to get started in the right directions, I started from the "other end", i.e. fixing the boring details and such before starting working on the user interface.

Now, my wait is over. The user interface is here, or the basics of it. One can pick fractals through a factory (wait for the plug-ins) and look at fractals. The setting docks are there, but not live and the viewer is just a QLabel i a QScrollArea - not very fancy.

This must be the only general fractal explorer not supporting Julia nor Mandelbrot... :-)