Trolltech developer Jens Bache-Wiig is working on a new style engine for Qt that can leverage the user's default GTK+ theme. This will make it possible for Qt applications to optionally share the GNOME look and feel when they are running in the GNOME desktop environment.

Qt has long had custom platform-specific styles that use native system theming APIs to provide a higher level of visual consistency on Windows and Mac OS X, but the toolkit has always drawn its own widgets on the Linux platform. The result is that mixing KDE and GNOME applications often results in an aesthetically confusing experience.

This problem can be mitigated easily on KDE with a special GTK+ theme engine that uses Qt widgets, but there wasn't previously any equivalent for GNOME users. Qt's current GNOME visual integration solution is the Qt QCleanlooks style, which is designed to loosely mimic GNOME's default Clearlooks engine. Bache-Wiig's new QGtkStyle, which uses real GTK+ theming APIs, provides a much higher level of visual consistency than QCleanlooks and makes simple Qt applications virtually indistinguishable from GTK+ applications.







Qt Designer with QGtkStyle

"Now that 4.4 is out, I finally found the time to kick off some new development and one of my pet projects these days is QGtkStyle. We already have QCleanlooks, icon themes, standard shortcuts and dialog buttons to integrate with GNOME, but to achieve true perfection we need to use the Gtk theme engine directly just like we do on Mac and Windows," Bache-Wiig wrote in a blog entry. "QGtkStyle does exactly this, and in addition extends and surpasses QCleanlooks in a lot of other areas as well. All group boxes are now flat style to blend better with GNOME dialogs. Icon theme support has improved, scrollbar buttons are disabled at edges and item view branches now support hover."

I tested it on Ubuntu 8.04 with Qt 4.4 and was very impressed with the quality. It's still experimental, but I found it entirely usable with Qt Designer, Dolphin, KWord, and other complex applications. I tested it with Ubuntu's default Human GTK+ theme and with my own relatively complex Murrina-based GTK+ theme. It was able to support most of Murrine's advanced features, including menu and scrollbar striping, but had a little bit of trouble with the gradient line that runs along the left edge of menus.







QGtkStyle and the Human theme







QGtkStyle and my custom theme

The source code is available for download from Trolltech's SVN repository, but remember that you will need Qt 4.4 to make it work. After the style has been compiled and installed, you can activate it for KDE applications with the KDE 4 systemsettings tool and for Qt applications with the Qt 4.4 qtconfig tool.

Further Reading