strontium90’s den

August 8, 2006

Moving to Qt 4

Filed under: Programming — strontium90 @ 8:30 pm

This has been a long postponed endeavor that I just had the chance to pursuit, and let me tell you, it turned out much less troublesome and much more enjoyable than what I was expecting. Qt 4 is a wonderful product, hats off to software engineers at Trolltech. :)

Of course I cannot review the product featureset in this entry since several items (mentioned below) in Qt’s excellent documentation summarize the Qt class library and associated tools extensively. I’d like to mention several points that have made me most happy with the product so far and will give some hints to get fellow Qt 3 developers started.

I’ve never been quite comfortable with GUI design tools and Qt Designer (although a mature application by now) is certainly no exception. I prefer to use Qt in C++ code and to this end the Qt APIs are famously elegant, neat and easy to learn. The good news are that they are cleaner and much more elegant now with Qt 4. Particularly revised object ownership and layout management conventions, which now completely decouple widgets from their layout managers, further simplify code and relieve developers from memory management concerns. Consistent simplification policy reduces many past APIs by providing sensible defaults to what used to be mandatory and often insignificant parameters and in some cases removes them altogether.The painting system has undergone a major redesign and now offers an array of important capabilities including gradients, alpha-blending, anti-aliasing, painter paths, built-in double-buffering for all widgets and solid support for SVG rendering. These of course offer very important primitives for raster and vector graphics applications built on Qt.

Rich text processing has been revamped into a complete framework decoupling document representations from accessing means. It offers facilities to describe hierarchically structured rich-text documents and facilities to manipulate them.

IPC and particularly multithreading has been improved and now that each thread can have its own event loop, signals and slots work across threads!

I think that seasoned Qt 3 developers should be able to port to Qt 4 with minimum hassle and without the need of any extensive training since from the developer’s point of view, key Qt concepts remain almost intact and the documentation set provides invaluable help on what has been changed and what’s new.

For a smooth porting process I think that it is best to start gathering information from a non-technical overview about what’s new in Qt 4, then having a broad understanding of the areas of incompatibility between Qt 3 and Qt 4 before delving into the details of what’s new in Qt 4 and reading the product whitepaper. The porting reference is an invaluable document, it describes the automatic porting process and addresses all areas of incompatibility and obsoleted functionality mentioning the new API where applicable.

Qt releases come with many examples included demonstrating idiomatic Qt programming and many of these examples are documented in current Qt 4 releases. Of these the official tutorial and the application example demonstrate many key features in action and probably are the first examples that have to be examined before looking on others.

At this point it is probably desirable to review some familiar features and technologies in the context of Qt 4 e.g. layout management, main window architecture and to learn about those that have significantly changed or were introduced in Qt 4, most importantly rich-text processing, the paint system and model/view programming.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.