Qt and Glib

Posted by Bradley T. Hughes on February 24, 2006 · 15 comments

Note: This is my first blog posting ever, so please bear with me. ;)

There has been quite some talk recently at Trolltech about how well Qt “fits” together with other software components on the X11 desktop. We do a fairly good job of it already by providing the QAbstractEventDispatcher API in Qt 4. This has allowed people to plug Qt into the Glib main loop fairly easily, resulting in an application that can use any of the Qt, GTK+, KDE, and GNOME APIs. This is quite powerful, but has one significant drawback: if your application is designed to allow third-party extensions (i.e. plugins), you have to know in advance what kinds of integration to provide. Consider a Qt application tries to load multiple plugins, where each plugin uses GTK+. If the Qt application did not provide some sort of integration into the Glib main loop, what happens when each of the plugins tries to? I have the solution… :)

Yesterday, I got Qt running on top of the Glib main loop. By using the QAbstractEventDispatcher API, I was able to completely replace the entire event dispatching mechanism of a Qt 4 application with less than 600 lines of code. What does this mean? No integration; the scenario above is now possible, since Qt would already be running a Glib main loop. I can now write an extension to my programs with any toolkit I want. Even more attractive is the idea that I can now write a Qt based extension to any GTK+ or GNOME program. Just think… I could write a plugin for the GIMP or for Eclipse, I could use the asynchronous GNOME VFS API. I’m sure there are possibilities I haven’t even thought of yet. And that’s the whole point: the possibilities are endless.

Of course, this is all useless if only I can do it. I envision applications and frameworks in the future that give Qt, GTK+, KDE, and GNOME programmers the same flexibility that Windows programmers get with COM and ActiveX. I’ve talked with Matthias (mostly to brag about what I had done), and he was very interested in getting this code into Qt, possibly as soon as Qt 4.2. We both agree: the ideal would be for all applications on the X11 desktop to use the same event dispatching mechanism. Here are Trolltech, we think the Glib main loop should be that mechanism…

QShare(this)

Possibly related posts:

  1. When being wrong is right
  2. Not yet Accessible
  3. New proof-of-concept UIKit based Lighthouse platform

3 trackbacks

The very first step towards integration of KDE and GNOME » The R Zone
February 24, 2006 at 9:20 pm
Tetromino weblog » Blog Archive » Qt4 + Glib = awesome
February 25, 2006 at 1:00 am
A Blog of Very Little Brain » In and out of context
August 18, 2006 at 8:00 am

12 comments

1 Max February 24, 2006 at 11:09 am
 

> Here are Trolltech, we think the Glib main loop should be that mechanism”

2 jayKayEss.com February 24, 2006 at 11:53 am
 

“Here are Trolltech, we think the Glib main loop should be that mechanism”

3 mobtek February 24, 2006 at 4:13 pm
 

Very nice, when this is in Qt 4.2 will give me more bragging rights about how awesome Qt is to my mates :P This would be a really powerful option to have.

4 Rudd-O February 24, 2006 at 9:23 pm
 

I just blogged about this on my blog. Sadly, your blog seems not to support Pingbacks. Please enable them.

5 hagaik February 24, 2006 at 11:56 pm
 

Hey that’s cool! I hope it makes it into 4.2..
But just clear something for me, does it mean that Qt would depend on Glib, or am I just thinking nonesense?

6 eoin February 25, 2006 at 10:34 am
 

Thats actually really cool.

Is there any performance issues with using glib? It seems to me that some extra hackery would have to go into glib to get the most out of its interaction with Qt.

Just a rambling though, I haven’t dug through glib or Qt at all :-D

Either way this is pretty darn neat, and I look forward to see what the devs can pull out of their hats with this trick.

7 Brandybuck February 25, 2006 at 4:44 pm
 

Will this mean that Qt and KDE will break everything GNOME releases a new Glib? It’s already a pain in the butt when a minor bump in the Glib version causes me to rebuild everything starting with a ‘G’, I think I might go postal if I had to rebuild everything with a ‘K’ as well.

8 vvl February 25, 2006 at 5:03 pm
 

Sweet, now I guess the only big hurdle would be getting identical themes/behaviour for both QT and GTK+ so that an app/desktop would be completely seamless?

9 bobef February 26, 2006 at 5:52 am
 

“I envision applications and frameworks in the future that give Qt, GTK+, KDE, and GNOME programmers the same flexibility that Windows programmers get with COM and ActiveX.”

I suggest you give the above programmers the same performace that Windows programmers get, and only after that the flexibility, because recently all my attempts to use Linux end up with the same conclusion: KDE is slow as hell! GNOME is slow as hell! It turns out (in my experince) that often a software that is made on pupose to run slow (to sell hardware) runs faster than open software. I can’t understand what’s the matter. Am I the only one to notice that the major and most usable desktop enviroments for Linux are so damn slow?

10 paul February 26, 2006 at 7:04 am
 

Why you have choose glib main loop as main dispatching mechanism?

11 Juan Linietsky February 27, 2006 at 2:16 pm
 

Hi! I’m very interested on this topic and have done some good research about it. Since I’m in the audio development community, having a way to do standard plugins that can instance interfaces without having to resort to really bad hacks (such as core/UI separation via IPC) etc has been a very needed goal. If you are interested (and since you dont provide any means of contacting you directly) please drop me an email.

Cheers!

12 Peter February 28, 2006 at 10:12 am
 

“Am I the only one to notice that the major and most usable desktop enviroments for Linux are so damn slow?”

Yep. :)

Comments on this entry are closed.

Previous post:

Next post: