Status Update

It has been quite a while since I last blogged. As always, there is not a single reason for this, but the major one is that have been swamped with work. This text will be a small re-cap and a way for me to start with a fresh-ish slate this year.

First of all, the Qt in Education material is finally completed. I was at the München Qt DevDays and presented what we had then. Since then the slides and exercises have been completed and received a polish. There is already a small errata in the Qt DevNet wiki. I choose to interpret this as a Good Thing – people are using the material.

Just after the new year, a team from Pelagicore attended CES. I did not go there this year (small kids change your priorities) but worked hard on a set of Qt-based demos that we ran there. The demos (and Pelagicore as a company) are focused on in-vehicle infotainment, or IVI as it is commonly written. Of course there are a million things that I as an engineer want to polish or add, but as a whole the event was a success.

So, there it is, a new starts. Now I will try to blog more frequently.

DLLs from Qt SDK

When installing the Qt SDK for Windows you get a set of pre-compiled Qt libraries as well as Qt Creator.

When using this Qt version for building an installer, it is important to pick the correct Qt dlls to ship with your application.

The SDK comes with two sets of dlls. One set resides in $BASEDIR/bin and the other in $BASEDIR/qt/bin. The former contains the dlls used by Qt Creator, while the latter are the dlls that you want to ship with your executable.

Thanks to Marcus for this tip!

QFtp needs login

First post with WordPress 3.0 – fingers crossed but so far it looks good!

I’ve learned a small detail today – QFtp requires login even if you do not have any username or password to give the server. Saves some time from debugging time knowing that calling login once fixes this. (Yes, me stupid)

For those of you learning Qt or wanting to get started with Qt, I will hold a session on the Kubuntu Tutorial Day. I hope to see you there!

Also, great rainy weekend. Got loads of stuff done ranging from catching up on some work to restructuring parts of the garage.

Pre-vacation Stress

It has been a long time since I blogged last. Life has been chaotic, and as June closes to an end, it is getting worse. However, I’ve promised myself to clear all current projects during June (apart from some continuously ongoing stuff) to have a fresh start after my summer vacation.

Loads of exciting things are happening this fall. Some highlights are:

  • I will start working full-time at my new employer, Pelagicore.
  • FSCONS will take place, and this year with more technical contents than ever and a specialized embedded track which I’m co-organizing.
  • I will continue with my QtLunch concept. If you are in the vicinity of Gothenburg and want to learn more about Qt and enjoy a good meal with fellow Qt users, drop me a mail!
  • I will blog more frequently… :-)

>Overload

>It has been quite some time since I last blogged. Lots of things are going on, so the time to sit down and reflect has been… let’s say limited.

The last week, I sadly missed foss-sthlm, due to snow. Apparently Swedish trains are built for the summer, so I hope that there will be another get-together later this spring.
I’ve also been working hard on my embedded Linux course. The course date is kind of tight on the Easter, but hopefully STF can find a nice crowd to work with.
Finally, I’ve been spending time trying to learn QtQuick (QML, Declarative UI). I’m really enjoying Jürgen’s blog on this, as the approach feels new to me.

Qt as GTK, again

Another set of night hours spent hacking on making the GTK API wrap Qt. I focused on adding functionality and not on cleaning up, so no code this time either. I just want to show the progress.

Wrapping Qt in GTK might seem like an impossible task, but the fact is that both toolkits, in turn, wrap the same APIs themselves. So, how does the progress look this far?

Upgraded Hello World (link)
The first example, upgraded hello world, works like a charm and does what is expected. There is only one change that has to be made to the example, and the need for it will go away when I’ve started cleaning the code.
Changes made to the example:
  • Replaced the gtk/gtk.h headerfile with my substitute.

Table Packing Example (link)

The next example, table packing, simply demonstrates the grid layout abilities of GTK. There seems to be a couple of pixels between the rows for some reason (I will investigate at a later point), but apart from that, everything works. The changes made are the same as for the first example.

Changes made to the example:
  • Replaced the gtk/gtk.h header with my substitute.

Manual Menu Example (link)

Robin Burchell (w00t) has attempted something similar in the gqt project (gitorious link). We will discuss how we can join forces ASAP (I’ve been sort of unavailable this weekend). The gqt project has clean code – look great. It employs a different approach than I when it comes to mapping signals/slots/events and for handling the construction of menus.

Robin mentioned that one of the major hurdles when mapping the APIs is that GTK uses a widget based structure for menus, while Qt uses QActions for menu items. To have a swing at this, I decided to attack the manual menu example next. It took some changes to the main approach of the wrapping effort, but now I think I have it sorted out.
Changes made to the example:
  • Replaces the gtk/gtk.h header file with my substitute.
  • The popup is always shown at (100, 100) as the GdkEvent structure cannot be cast to a GdkEventButton structure.

Manual Menu Example
Another benefit of doing the manual menu example was that I had to have a better look at the events mechanism. As it seems, the “event” signal hooks into all events (like a Qt event filter). This means that there has to be a general event filter, as well as specific event filters (for when connecting to a specific event such as “delete_event”). This kind of breaks my idea of splitting out the code for creating a specific GdkEvent for each type of event in a separate class, so I need to think a bit about that (shouldn’t really be a major issue – I just don’t want code duplication).
Back to the menu widget versus action approach. As it seems, the QAction and QWidget classes’ common base is the QObject class. Thus all pointers to GtkWidget, GtkWindow, etc. needs to be pointers to QObject. That way, the menu object can be made to match quite nicely. The downside is that the code already contained quite a lot of casts. Now it has even more. For instance, a trivial function such as gtk_container_set_border_width needs casting:
void gtk_container_set_border_width(QObject *o_w, int spacing)
{
   QT_WIDGET_ASSERT(w)w->setContentsMargins(spacing,spacing,spacing,spacing);
}
The QT_WIDGET_ASSERT macro creates a QWidget pointer named w, by casting o_w using qobject_cast and then asserts that the pointer isn’t null. I’m not sure of the performance penalty of this, but I guess there is one. However, to compensate, all of GTK’s GTK_WINDOW, GTK_BOX, etc. are instead defined as simple pass-through macros. This means that performance wise it is a race between GTK_CHECK_CAST and qobject_cast.
I did consider putting the qobject_cast calls in the GTK_xxx macros, but that would not work. For instance, gtk_menu_shell_append can place a QAction in either a QMenu, or in a QMenuBar. As the function is given a QObject pointer, it can now determine (by casting) if the container is a QMenu or QMenuBar and act accordingly.
So, where to next? I belive in fixing the known bugs before continuing. Especially when working on a project such as this, which I suspect will backfire anytime soon (it has been too easy this far). This means that the next step is to do something about the GdkEvent structures to get the popup of the manual menu example to work properly (now it appears at a static location). After that? Cleaning and merging with gqt…