Development on the Qt


The introduction of Microsoft Corp.’s Visual Studio .Net drew a lot of attention to issues such as whether C# is preferable to Java and how the .Net framework compares with the Java 2 Enterprise Edition framework.

My recommendation is to go with Java and J2EE, in part because they’re maturing so quickly, but mostly because they don’t tie you to Windows as a development platform.

But with all this fuss being made about C# versus Java and the competing frameworks, it’s easy to forget that there are many other options for application development. My favourite is Qt, from Trolltech AS. The latest version of Qt, Version 3.0, is the foundation for the phenomenal K Desktop Environment (KDE). I’m crazy about KDE 3.0, so it should come as no surprise that I’m equally enamoured with Qt.

Qt is a set of C++ libraries and visual-development tools. It’s available for Windows, Mac OS and just about every flavour of Unix including Linux and many handheld devices, such as the Sharp Zaurus. The Qt application program interface (API) is virtually identical for all desktop platforms, so you can create a single source-code base and should be able to compile it without modification for all the supported operating systems.

The latest version of Qt includes support for SQL access to databases via plug-ins that support Open Database Connectivity, Oracle, Sybase, MySQL and PostgreSQL. It has a broad range of XML objects and functions and supports OpenGL 3-D graphics, customizable graphical user interface themes, layout managers to help an application look its best on any platform and more.

Trolltech is also working on a project that will allow you to add a JavaScript-like language for your Qt applications. This will give your Qt-based applications scripting facilities, much like today’s productivity applications support various forms of Basic scripts, such as Visual Basic for Applications.

The Qt API has expanded so dramatically during the past couple of years that one might get the impression that it’s getting too bloated to be useful. But you can get the source code to Qt, and the configuration step for compiling your own Qt libraries makes it very easy to eliminate the features you don’t need, so you can trim Qt down to nearly any size you want.

The handheld support is especially fascinating. Trolltech offers a complete handheld desktop environment called Qtopia. It includes Java support and comes with dozens of applications, including a full range of personal information management programs like those you get with a Palm device.

All of the aforementioned software is open source and free, as long as you distribute your applications according to the requirements of the GNU General Public License. (You must also make your source code available.) If you want to sell proprietary applications based on Qt, you have to pay licence fees to Trolltech. The licence fees seem a little steep at more than US$3,000 per developer for the enterprise edition of Qt, but it’s well worth it.

Some programmers balk at using Qt because it relies on C++ instead of C. Personally, I suspect that many of them claim the problem is with C++ but that their real reluctance lies in their inability to conceptualize object-oriented programming techniques. That’s not to say that C++ is an ideal language. Java was designed to eliminate many of the weaknesses in C++, and it does that job very well. But there’s still room for C++ in your arsenal of languages.

The other objection to C++ is that it’s slower than C. But let’s face it – we gave up some speed when we graduated from assembler to C many years ago. I don’t see why we can’t give up a bit more speed to gain the advantages of C++ and tools like Qt. Certainly, if you’re considering Java or C#, you’ve already decided that raw speed isn’t the determining factor in your choice of language.

Java boasts the best degree of platform neutrality. C# could eventually give Java and C++ with Qt some serious competition, if anyone successfully ports the .Net framework to other platforms. But if you want to use the lean, mean C++ to build applications that will have the widest audience, I don’t see how you can beat the combination of C++ and Qt.

Petreley, who writes for Computerworld (U.S.) is a computer consultant and author in Hayward, Calif. He can be reached at