JonHoyle.com Mirror of MacCompanion
http://www.maccompanion.com/archives/october2005/Columns/AccordingtoHoyle.htm

 

Newsworthy Events





It's Your Net - Make it Pay!

MaviShare

According to Hoyle...

Cross-Platform Software Development from a Macintosh Perspective: Qt

by Jonathan Hoyle

jonhoyle@mac.com

October 2005


Last month we began a series of articles discussing the many options of cross-platform development available to the Macintosh software developer.  Over the course of the next several months, we will examine these approaches.  These will include both freely available and commercial packages, covering different programming languages, and different levels of expertise.  Whether you have been a Macintosh programmer for 20 years or you are just starting out, there is a cross-platform solution available, which I hope to introduce you during this series.  We first begin by looking at some solutions available to the C++ programmer.  This month, we review the application framework Qt by Trolltech.


Qt History & Overview

Qt has been a cross-platform solution about 10 years.  Unfortunately, for most of that time Trolltech's idea of "cross-platform" was Windows and Unix only.  Trolltech finally released a Macintosh version of Qt 3.0 in October 2001, just around the time Apple released Mac OS X 10.1.  So Qt could take advantage of all the new power of Mac OS X, Classic has never been supported.  Although there have been some improvements and bug fixes to Qt/Mac over the past four years, the first significant upgrade came in July 2005 when Trolltech upgraded its entire Qt line to version 4.0.

Qt is arguably the most powerful cross-platform framework available today.  Using this framework, developers can compile applications for Windows, Linux and Mac OS X.  Without the burden of supporting Classic, Qt is a very modern and up-to-date framework.  It weighs in at about 400 C++ classes, covering everything from simple dialogs, controls, sophisticated OpenGL classes, database connectivity and more.  For those not needing the full power of the Desktop Edition, Trolltech offers both a Desktop Light and a Console edition.  There are a number of RAD-like tools that integrate well into the Qt framework, such as QtDesigner for creating GUI's and QtLinguist for localization.  The documentation is also very impressive, with a separate tool called QtAssistant, which manages it nicely.

In addition to these commercial licenses, Trolltech also offers an Open Source Edition at no cost; however, this version does not include some features, such as the database module.  Moreover, Qt/Open Source is offered under the GPL license, making it available only to other open source developers.  Trolltech was quite clever offering an open source license; it allows developers to try out the package for personal freeware development, and thereby be able to recommend the product to their employer, who might more ably afford the commercial version.


Creating Applications with Qt

Mac developers will not find Qt as easy to use as Windows developers would, especially the online information, which is fairly sparse for the Mac.  Qt/Mac applications are built with Xcode (as Qt is incompatible with CodeWarrior), but when searching the Trolltech web site for a sample project, the response is a curt: "We do have integration with Project Builder and Xcode, but I am afraid that we have no examples or tutorials on how to do this. Typing the following line in a shell will create a Project Builder project: qmake -spec macx-pbuilder name-of-project.pro."   The feel of the environment is also a bit awkward getting started, although once you get going with Qt, adding additional classes to extend functionality get easier.  I would strongly encourage anyone interested in developing with Qt to pick up a book on it, as it will help you through the many gotcha's that are likely to crop up.  There are many books available on Qt, but most of them are very Windows-centric and cover much older versions of the framework.  The only one I have seen which even acknowledges the Macintosh is C++ GUI Programming with Qt 3.

Qt is compatible with Xcode 2.1, so you can create Universal Binaries (applications which will run natively on both PowerPC-based and  Intel-based Macintoshes).  On Windows, Qt supports the Microsoft Visual C++ and gcc compilers for commercial development (gcc only for Open Source development).  Developers will not find a richer, more powerful framework with which to create cross-platform applications.  Using Qt's tools, creating professional looking applications is very easy, and the framework is fairly robust after so many years of being debugged.  Though not as Macintosh-friendly as Interface Builder, it is the one of the best cross-platform framework available today.

Perhaps the best known Qt success story is the implementation of the popular open source KDE environment for Linux.  Other applications which have been created in Qt include Adobe Photoshop Album, the Opera web browser, not to mention the Mac OS X versions of KOffice and PostgreSQL GUI Client.


Pricing

Qt has a number of licensing strategies, including those for commercial, academic and open source.  The Open Source version does not come with any technical support and is freely downloadable.  It is offered under the restrictive GPL license, which means that any software you create with it must itself be open sourced under GPL.  If you plan to commercialize your product or simply do not wish to make your source code available, you must use one of the commercial licenses.  Visit here for more information on the terms of GNU's GPL license.

Qt's commercial licenses come in three flavors: Console, Desktop Light and Desktop.  Anyone wishing to use Qt's powerful GUI capabilities must buy at least at the Desktop Light level, and should probably consider the full Desktop version if he needs Qt's database and networking classes.  The Console Edition is designed for those creating server or console applications.  Qt's pricing is tiered based upon the number of licenses being purchased.  A single license of Qt ranges from $1780 for the Console Edition to $3300 for the Desktop Edition.  Note too that each platform requires a separate license.  This means that a single developer wishing to create an application for both Mac OS X and Windows using the Desktop Light Edition would have to purchase two licenses, totaling a whopping $2990.  Visit here for a detailed breakdown of Qt's pricing.


Conclusion

As impressive and powerful as Qt is, its pricing is daunting and places it well outside the reach of the private developer.  Although it is an excellent solution for Open Source developers, it is an expensive route for everyone else.  It also shows its Windows and Linux heritage, as the Mac OS X port still feels more like an afterthought.  For example, there is no facility to work directly with .nib files created by Interface Builder, to which a Macintosh developer would be accustomed.  Freeware authors will likely find Qt to be the cross-platform strategy of choice, due to its richness in features and powerful capabilities.  Commercial and shareware developers, however, will not find the case for Qt so compelling.  With the large number of low-cost and no-cost frameworks available today, it is unnecessary to spend four figures creating cross-platform applications.  Mac developers would do better saving their hard earned dollars for next year's Intel-based Macintoshes.  Unless you have money to burn, or wish to develop open source software, I recommend passing on Qt.


Coming Up Next MonthwxWidgets!

About Us | Site Map | Privacy Policy | Contact Us | ©2005 MPN LLC.

http://www.maccompanion.com/archives/october2005/Columns/AccordingtoHoyle.htm http://www.maccompanion.com/archives/october2005/Columns/According_to_Hoyle_2.htm