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… :-)

Moved from Blogger

So, blogger is shutting down the ability to publish via ftp. This more or less forced me to move away from their service. I decided to switch to a WordPress install on my own server (since I have experience from that). The moving process was easier than I thought it would be, but still not pain-free.

I started the move by backing up my blogger entries. This gave me an XML file of about 2 MB. I’ve heard rumours of people with large file sizes here running into time out issues.

The next stage was to back up all contents of my ftp site – if blogger felt that they had to mess around with it. I still want all my old links to work.

Then I switched to blogspot hosting. This worked great. As I wanted, all my images were kept on my server and the entries still referred back to the correct location.

Moving on, I installed WordPress. Did a quick check of all the settings. Added a non-admin user. Then clicked the big import button. I had to authorize the import and pick which of my blogs to import (I have four). Then the process of importing started and passed without any hiccups. Finally, I assigned the non-admin user as the author of the entires (the import button changes to set author when the import is completed).

What broke then? All entries and titles start with a >, looks like broken XML parsing if you ask me – but I’ll live with it. Also, source code seems to be broken right now, but I might be able to hack at that using css.

To summarize – it went better than expected, but not 100% perfect. Now I’m off to hand patch my atom and rss feeds for various planets to announce this move!

PS. A tip – you ought to be able to alter the blogger theme to redirect users to your new location. To achieve that, make the change BEFORE switching to blogspot hosting, as you cannot switch back.

>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…