What's New in Qt 2.2.2
Pages: 1, 2
Properties -- useful or just added weight?
One relatively new feature that's heavily used by Qt Designer is the property concept. No longer is it necessary to use functions to get and set certain properties of widgets, such as font. Instead, we have a property mechanism that is implemented as a moc (Meta Object Compiler) macro, Q_PROPERTY. Together with this feature comes a new class, QVariant, which is a union for the most common Qt data types -- this enables a single mechanism to handle the property settings.
I've been told that the original intention with Q_PROPERTY was to make it easier to create bindings of Qt to scripting languages -- however, neither PyQt nor PerlQt, the currently best developed bindings, really need the feature. Indeed, it is quite possible to use functions everywhere, instead of properties.
As it is, the property mechanism is completely superfluous, creating a second way of doing the same thing, and I find the QVariant class to be a monstrosity that keeps reminding me of Visual Basic's Variant data type. I think Qt would have been cleaner and more usable without it.
New table widget is hot; others so-so
A great addition, and one that hasn't received nearly enough press, is the new table widget. This is finally an editable spreadsheet-like control. Users of Qt have been clamoring for this for years, as it is absolutely essential for all kinds of business and database applications. No longer have people to work with the difficult old QTableView, which was prone to all kinds of nasty bugs.
In the category "nice, but I don't need it" falls the QDial widget, a rounded range control like a speedometer.
The QMultiLineEdit widget is still relatively underpowered -- it doesn't support rich text and is completely line oriented, being built on QTableView. For Qt 3.0, a new and fancy QTextEdit widget is being promised, which will support rich text just like the display-only QTextView widget that is included in Qt 2.2. KDE developers have an advantage here, as they can embed the powerful KWrite text-editor widget or the KWord word processing widget in their applications through the KParts mechanism.
The widget appearance has improved -- the Motif style is no longer exactly Motif, but a bit more elegant. An SGI-like style has been added, and a GTK-like style. Both reproduce the look and feel of these toolkits very well. My favourite style is still Platinum, which evokes the updated Mac look introduced with Mac OS 8. And it's as easy as ever to create new, fast widget-themes yourself.
There is now support for cute fade and scroll effects for popup and MDI windows. MDI is relatively new too -- Qt 2.1 introduced the QWorkspace class that makes it possible to write windows-style MDI applications. The trend in user-interface design is going to SDI everywhere, with one window for each document, but MDI is certainly very useful for a large class of applications, such as IDEs.
Troll Tech has drawn much criticism for their licensing approach in recent years. When they first made their library available for free software development years ago, I interpreted it as a gesture meant to support free software, not as a nasty corporate plot to get as many free demos as possible. But this was long ago -- in a time when people were actually using binary-only toolkits like XForms.
The success of the KDE desktop has changed that, and Troll Tech has finally decided to make Qt for Unix/X11 available under the GPL license. This is important, because it should help dampen a lot of unfair criticism, but in practice, little changes. The only new "right" is to distribute modified versions of Qt instead of distributing patches. Since we're talking GPL instead of LGPL, developers of closed source software still have to buy a developers license from Troll Tech, and until someone takes the GPL version of Qt and ports it independently to Windows, nothing changes for Windows developers, either.
The addition of a GPL license for Qt Embedded can become quite important, though. Even though X11 is still serviceable, it is showing its age, and some widely desired effects. such as anti-aliased font handling, are difficult to implement. Qt Embedded, which runs just as well without X11, can change that. Imagine a KDE 2 desktop that runs on Qt Embedded -- it would look very professional, won't carry any excess baggage, and would be an attractive proposition for vendors of distributions geared towards beginners.
Qt has always been a cleanly engineered, full-featured toolkit. In the past, people have complained about its look-and-feel (although at the time when Qt offered a choice between Windows and Motif look-and-feel, no other toolkit existed that gave as much choice), but with 2.2.2, that should be over. Another serious objection to Qt -- the lack of a professional, extendable GUI designer -- has been answered too. By offering support for Unicode, localisation, and internationalisation both on Unix and Windows, Qt provides a strong basis for modern application development. Besides the rich set of widgets, Qt now offers many utility classes with well-thought-out interfaces that are easy and safe to use.
In sum, Troll Tech have created a complete environment where developing cross-platform applications in C++ has become as easy, if not easier, as developing in Java.
Boudewijn Rempt is a senior developer with Tryllian, a mobile agent company. He has worked with PyQt since its inception.
Discuss this article in the O'Reilly Network Forum.
Return to the O'Reilly Network Hub.