Skip to content

First Thoughts on Qt4

Saturday, 10 July 2004  |  rich

Last night I downloaded the Qt 4 preview and had a play with it, so far I'm very happy. The new painter code seems great and the GL painting demo suggests a lot fun ideas.

Qt 4 solves one of my big annoyances with the Qt API by introducing a common base class for items in list views, tree views etc. This change will make it much easier to let the user choose how information is displayed as we can have dialogs that switch between iconviews, listviews and trees without having to write the same code three times. In fact, when combined with the new model-view facilities (which I have yet to examine) this may be something that can be encapsulated in a single widget.

The changes to QObject and moc were a big worry for me because they have a big effect on the generic object proxy used in kjsembed. I've had a look over the changes here and they don't seem to bad. The actual code generated by moc has changed a lot (and looks like it will be more efficient) but the API for QMetaObject seems roughly the same. There are changes to some of the details of querying signals and slots but they look like they will replace code in KJSEmbed nicely.

The process of calling signals and slots appears to have changed significantly and is now handled via two new event types InvokeSlot and EmitSignal. This is a major change as in earlier versions, signals were invoked directly. I think though that this is very positive change as it means there is a single mechanism by which this sort of interaction takes place. One would hope that this change also means that you can use tricks like event filters and synthetic events with signals and slots which will be very powerful. This could mean that the existing code in KJSEmbed that allows you to override event handlers of C++ objects from a script could be trivially extended to allow you to override the handlers for arbitrary slots. As with event handlers, this would work even if the object is one there is no binding for C++ class you want to extend.

The painter changes offer some nice possibilities for kasbar - I'll be able to provide some really cool animations etc. for things like 'the task wants attention'. I hope the range of painters will be extended to cover images, but for now this side of things is looking good.

One thing that did disappoint me slightly was that there wasn't a new baseclass added for 'view objects'. I was hoping to see a single generic base class that worked for widgets, objects and canvas items providing generic support for nestable rectangles. This would be the class used by layouts etc. and would let you use layouts in canvases etc.

Overall I'm very impressed, the preview suggests that Qt 4 will be a major improvement. I look forward to it's release.