Mainstream graphical applications for the Linux desktop are generally developed with either Gtk+ or Qt. These open source development toolkits supply user interface frameworks and other components that are needed to build desktop programs. Although Gtk+ has historically been favored by the major commercial Linux distributors, Qt's numerous technical advantages and growing relevance in the mobile industry are increasingly difficult for Linux vendors to ignore.

In a blog entry posted this week, Canonical CTO Matt Zimmerman outlined how the capabilities of Nokia's Qt development toolkit can benefit Ubuntu. Some of the specific advantages that he highlights include Qt's strong corporate backing, robust suitability for cross-platform development, and increasingly rich support for touch interaction.

"We want to make it fast, easy and painless to develop applications for Ubuntu, and Qt is an option worth exploring for application developers. In thinking about this, I've realized that there is quite a bit of commonality between the strengths of Qt and some of the new directions in Ubuntu," he wrote. "No single solution will meet all developers' needs, of course, and Ubuntu supports multiple toolkits and frameworks for this reason, but Qt seems like a great tool to have in our toolbox for the road ahead."

As a third-party Linux application developer who has experience with both toolkits, I'd warmly welcome stronger support for Qt in Ubuntu. In my experience developing Gwibber (a Gtk-based social network tool I created that is included in Ubuntu and other Linux distributions), I have consistently been frustrated with the limitations of Gtk+ and its unsuitability for producing the kind of user interface that I want to offer my users.

Over the past few years, Qt has advanced at an extremely rapid pace and has gained some remarkable capabilities that make it radically easy to achieve things that would be exceptionally difficult and time-consuming to do with Gtk+. Qt significantly boosts developer productivity, lowers the barrier to entry for developers who are new to the platform, and offers a much higher level of cross-platform portability. I think that offering Qt as a standard part of the Ubuntu desktop installation would enrich the platform by opening the door for better third-party software.

Qt 4.7, which was released last month, introduced a new framework called Qt Quick that is especially conducive to rapid development. I've been experimenting with Qt Quick myself ever since the earliest experimental versions were made available in public source code repositories. It allows developers to build sophisticated user interfaces with a simple declarative scripting syntax and bind those user interfaces to data models that are implemented in C++. This pairing offers a great mix of performance and productivity that looks to be a good fit for Ubuntu.

It's also worth noting that the Qt Quick declarative scripting language, called QML, can be used by itself without C++ to build relatively powerful applications. This could also be useful for Ubuntu because it would make it easier for users who don't have a lot of previous programming experience to start building their own software. Such a low barrier to entry really meshes well with the vision of user empowerment that is at the heart of Ubuntu's great development tool projects, such as Quickly and Ground Control.

A point that I think often gets overlooked in the toolkit debate is that adopting Qt doesn't necessarily imply ditching GNOME or switching to KDE. As we discussed in our review of Qt 4.5 last year, Qt has relatively robust support for Gtk+ theming, including conformity with the GNOME HIG and support for native GNOME dialogs. When everything is properly configured, Qt applications look entirely at home in GNOME environments. Adding a standard Qt library stack to a fresh Ubuntu installation requires only 16.5MB of packages, which expands to approximately 50MB on disk.

I'm currently working on a tutorial for Ars that will demonstrate the technical advantages of Qt Quick for mobile and desktop development in a more comprehensive way. It's not ready yet, but I want to share a sneak peek in this article to illustrate the kinds of things that Qt Quick can be used to accomplish.

One of the demo applications that I built for the tutorial is a front-end for the RTorrent BitTorrent client. The user interface, which works well on both desktop computers and touchscreen-enabled mobile devices, has some nice animated transitions and pulls the file icons from the user's default theme. Thanks to Qt's portability, I was able to get it working on Mac OS X and Windows in addition to Linux, my preferred environment. I actually designed it with MeeGo in mind, and I look forward to testing it on an N900 when MeeGo is a bit more usable on that device.

The implementation consists primarily of QML layout descriptions, but also has a small amount of C++ code that communicates with RTorrent's XML-RPC API (you can look forward to seeing the complete source code in my upcoming tutorial). It was a weekend project that required surprisingly little effort. These kinds of applications are trivially easy to make with Qt.

Some historical context

Qt, which was created by a Norwegian software company called Trolltech, was originally made available under a dual-licensing model. Open source software developers could use it at no cost, but commercial developers who used it to build proprietary software had to pay licensing fees. This model allowed Trolltech to build a business around Qt that funded their efforts to improve the toolkit, but it created some barriers to adoption for the major commercial Linux vendors. The model later changed substantially following Nokia's acquisition of Trolltech, resolving the original problems that had prevented Qt from becoming the dominant Linux toolkit from day one.

Gtk+ is distributed under the terms of GNU's Lesser General Public License (LGPL), which means that it can be used freely in both open and closed-source applications. The major commercial Linux vendors originally chose to back Gtk+ because its more permissive license allowed commercial software developers to use it without paying a licensing fee. A toolkit that enables royalty-free commercial Linux application development is critically important for attracting a diverse ecosystem of independent software vendors (ISVs) to the operating system.

Qt has always had a modest technical edge over Gtk+, but it was not enough to outweigh the licensing issues during the early days of the Linux desktop. The gap in quality began widening substantially when Qt 4.0 arrived in 2005 with major improvements, however, and has continued to grow rapidly. Although the high licensing costs deterred adoption among Linux vendors, Qt's technical merits allowed it to gain considerable traction among software industry heavyweights. It is already used today by Google, Amazon, Skype, Adobe and many others.

The real game-changer that redefined Qt's role in the Linux landscape was Nokia's acquisition of Trolltech in 2008. Nokia had spent several years struggling to make Gtk+ suitable for mobile environments with the Hildon toolkit for Maemo, but eventually determined that Gtk+ just wasn't going to meet its needs in the long-term. Acquiring Trolltech gave Nokia an ideal toolkit for moving its next-generation mobile strategy forward.

Nokia relicensed Qt under the LGPL last year, eliminating the major barrier to ubiquitous third-party adoption. As I predicted in my article at the time, the move deeply gutted ISV support for Gtk+, especially in the mobile space. When Nokia and Intel announced MeeGo, their combined mobile Linux platform, they positioned Qt as its standard application development toolkit. The once-promising GNOME Mobile initiative lost practically all of its momentum.

Qt can bring third-party developers to Linux

Although Gtk+ still has value and there are a number of reasons to continue using it for building native Linux software, Qt is now the obvious choice for ISVs that are targeting multiple platforms. Qt makes it exceptionally easy to conform to the native look and feel of the underlying platform or build a totally custom user interface that is optimally suited to a target device or form factor.

As Nokia and Intel bring MeeGo to a wide range of devices, it's going to attract some major commercial software vendors. It would be relatively easy for those software companies to bring their mobile Qt applications to the Linux desktop using the same code that they use on MeeGo. Qt is specifically designed to make that easy. This would be a huge win for desktop Linux because it would bring third-party applications that would not otherwise be available.

It's worth noting that some prominent mobile software vendors are already eagerly embracing Qt due to Nokia's support for the toolkit. Mobile video streaming company Qik, for example, is working on an experimental Qt-based port of its popular application with the aim of bringing it to MeeGo.

Gtk+ is not dead, as evidenced by the excellent Gtk+ hackfest that is currently in progress, as well as some of the nice improvements that are coming for Gtk+ 3.0. I'm increasingly skeptical, however, that Gtk+ will be able to catch up with Qt as Nokia continues to push the toolkit forward faster. The factors that compelled the GNOME-centric Linux vendors to favor Gtk+ during the early days of the Linux desktop are no longer relevant. If they want to continue delivering a competitive user experience, I think they need to either significantly boost their investment in Gtk+ or start seriously considering the possibility of making Qt a first-class part of their environments.