Introducing QGtkStyle…

Published Tuesday May 13th, 2008
61 Comments on Introducing QGtkStyle…
Posted in Labs, Qt, Styles, Uncategorized

textedit with gtkstyle

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. 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.

spreadsheet example

The style is already available right now as a Qt 4.4 plugin on Labs and given that you can accept the normal disclaimers about using unreleased and experimental code, you can start playing with it immediately.

This is how the Arora browser looks:

clearlooks style

All the above shots were taken using the “Clearlooks” engine. Here are a few alternatives:

Ubuntu Human:


And of course the unforgettable Raleigh engine:

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Labs, Qt, Styles, Uncategorized


Peter says:

Great, this together with your Cocoa work (assuming the Cocoa port uses native widgets or at least rendering), makes Qt much more attractive choice for x-platform development (because I *do* care about native look and feel on all common platforms, including Ubuntu, and Qt couldn’t deliver for GNOME desktops…)

IAnjo says:

Very cool! With gtk-qt4-engine and qgtkstyle the linux desktop will look more uniform, and even cooler. Rock on!

(I just wish that someone made a tk-qt or something like that, still wondering why the hell tk uses native widgets on windows, but butt-ugly old home-made ones on linux?)

cartman says:

Very nice but doesn’t compile on Ubuntu Hardy with Qt 4.4 :

Jens says:

@cartman: Thanks. Should be fixed now and happily compiling on 64-bit Hardy. Though it might take a little time for the svn mirror to get updated. I’ll try to set up a bug reporting mechanism on the labs page. I hate to have stack traces in the comments…

WindowsClassicStylePerfections says:


Thank you.

Well done! I’m now waiting for QFileDialog::getOpenFileName() to display the native dialog under Gnome. I have tried to do that myself, but I found problems integrating GLib’s main loop with Qt’s. There has to be a way…

Nils Jeisecke says:

It’s great to have a desktop aware style for gnome now. Can we hope for QQtStyle? Whenever you need a deploy a binary incompatible Qt lib with your application, it won’t fit on any KDE Desktop as it won’t use the “native” Qt libs. Could this be done?

Thank you.


Thiago Macieira says:

All Qt styles are “QQtStyle” πŸ™‚

The Plastique style is meant to integrate under the KDE 3 environment, but like the Cleanlooks and the Windows styles, it’s just an “imitation” of the actual styles, not the native thing. It’s not possible to load KDE 3’s Plastik inside a Qt 4 application, since that would pull Qt 3 along with it, thereby causing incredible crashes.

As for the KDE 4 integration, it’s the Oxygen or Ozone styles. Or any other KDE 4 style. All Qt applications natively use them.

Unless you statically link your application, that is.

JB says:

This a great news and a great relief for many users.

May this project go on!

Ian Monroe says:

Now someone just needs to port the gtk style engine from Qt3 to Qt4, so that gnome apps look good in KDE. πŸ™‚

Jens says:

@Ian : Someone already did that πŸ™‚

TorbjΓΈrn Lunde says:

This is awesome!

I’ve always had alot of respect for QT-plattform, but lack og GTK on Linux kept me from using it.
I’m a GNOME guy, but KDE does have some wonderfull apps.

Correct me if I’m wrong, but this would make QT work on more plattforms(with native looking) GUI than wxWidgets?

Sutoka says:

Very neat work! Though it does raise an interesting question… what’d happen if your GTK theme was the (Qt4 port of) GTK-Qt, and your Qt style was QGtkStyle? I could see me purposely trying this and making my computer explode… Maybe someway to blacklist that specific engine in QGtkStyle so you don’t result in an infinite loop? πŸ˜›

Andrew says:

Is it *really* impossible to create Qt4 engine that will use native Qt3 styles? Maybe, there’s some possibility of “isolation” of Qt3 and Qt4 so they would not interfere?

Nils Jeisecke says:

@Thiago: As the Qt styles are implemented as plugins, an application dynamically linked to a custom Qt shared library will most likely fail to load them because of incompatible build keys. So no KDE style will be accessible by that application. Please correct me if I’m wrong.


jens says:

@Sutoka: It should already blacklisted on startup and fall back to cleanlooks. The Qt4 one for the reasons you mention, the Qt3 one because of namespace issues. You can still make your computer crash spectacularily if you change your GNOME theme to one of these at runtime and I do not yet know if I can completely resolve this issue.
@Andres: In short no. The slightly longer answer is maybe but it would require recompiling Qt4 and all of your Qt4 apps using a separate namespace. If you do this you could theoretically use the QGtkStyle combined with the existing GTK-Qt theme as suggested above to get KDE3 styles with Qt4. I havent tried it and would be rather surprised if it worked πŸ˜‰

Thiago Macieira says:

@Andrew: Impossible? No. But it would require a special Qt build that used namespaces and integrated with Qt 3. Or some kind of out-of-process solution. Either way, too complex.

@Nils: That is correct, but the build key is very short on Linux. Most builds should be compatible. (In fact, I want to remove the “no-stl” part from it)

Kevin Dean says:

Excellent! I’ve been waiting a long time for this and I’m glad to see that It’s been done as a native part of Qt. With several of my favorite projects adopting Qt you guys are doing a lot to make me want to use Qt in my apps. Kudos to the developers for addressing realistic issues!

A major difference between the GTK and Qt modes of operation is that when you press the Alt key in a Qt app, it engages the menu bar; on GTK, it does nothing, and you have to press Alt with the trigger key to open any of the menus. On the Cleanlooks style, the Alt key does engage the menu, but it does not show, so you may not know that you are no longer working on your document. This is a bug which needs fixing, so I suggest not replicating it in this style – either a styling should reflect the behaviour of the Alt key in Qt, or Qt should be patched to disable this behaviour, and perhaps this is preferable when the intention is fitting an application into GNOME.

TreviΓ±o says:

A dream has become true :P.

Anyway… I knew about Gtk-qt tool, but when Gtk itself will do this too (without 3rd party projects)?

I do think that this is a major issue on Linux (X11 based, in general) systems, and you’re solving this!

Marcos says:

Γ“tima notΓ­cia, isso que faltava…

anon says:

Outstanding! Now Qt-/KDE-based applications can lag to all Hell and back, too! Good job πŸ˜€ (But seriously, this outta make a lot of people happy!)

meep says:

just compiled this and its pretty damn impressive πŸ™‚
question: is there any chance of using native font rendering in the future.

Sikon says:

Please add a COPYING file to SVN, so that it can meet Ubuntu packaging requirements.

Andrea Ratto says:

This is just what the GNU/Linux desktop needs! I am a Gnome user and I never install any qt/kde apps because they look and behave differently.
I hope that this project and its countepart gtk-qt-engine become stable and fast so that some integration can happen between Gnome and KDE. Hopefully this would lead to less duplicate efforts and better apps for the user.
Thanks guys for this missing piece, keep working on it!

Teodor Baciu says:

I think this is the way to go for QT on the linux platform. Excellent work, can’t wait
to see the final release.

evgen says:

$ qmake Unknown replace function: qtLibraryTarget


Felipe says:

That’s very nice!!

darkelf says:

Thank you! I hope we will see it in the ubuntu repositories soon…

Brain Fury says:

I love you guys for this.

PCMan says:

Awesome!! Amazing!! Just what all of us were waiting for.
Finally, someone got the job done. Thank you very much!
I tried to develop something similar last year, but I failed.
Your implementation looks perfect! Finally we have
unified look & feels for different toolkits.

I just did some tests and your program works very well.
The appearance was almost perfect, and performance was
quite acceptable. The source code was also clean and readable.
Great job!

Some suggestions:
1. Use XSettings instead of GConf. This can make things more portable.
Other gtk+ desktop environments such as LXDE, XFCE, and ROX don’t use gconf.
XSettings is the standard way. You can get the implementation for XSettings support
in gtk+ source tree. IIRC it’s under gdk/x11 directory.

2. A even better way is to connect to “notify” signal of GtkSettings and “change” signal of
GtkIconTheme. Those two gtk+ objects can get retrieved by calling
gtk_settings_get_default() and gtk_icon_theme_get_default().
With this signal/slot mechanism, you can monitor the change of gtk+ widget theme and icon
theme. Then you can reload your qt style to reflect the change of gtk+ theme on the fly.
Since gtk+ itself handle this via XSettings, you don’t need to touch XSettings yourself.
Also, you can get the font settings in the same way by getting the “gtk-font-name” property
of GtkSettings object.

Looking forward to the next release. Great job! Thank you very much.

Mildred says:

Thanks a lot for that style πŸ™‚
Just a question, How do you set the gtk style for the arora browser ? It doesn’t seems to work.
I used systemsettings of a KDE4 installation I have. The style in systemsettings has changed but it doesn’t change the style in arora.

jens says:

@Matthew : I probably cannot fix the current menu behavior in the style, but it will certainly be considered for Qt 4.5.
@meep : We basically render fonts more or less the same way as GTK so your problem can most likely be solved by creating a properly set up fonts.conf file in your home directory with correct hinting and subpixel settings.
@evgen: you are trying to compile with Qt3 qmake. You need 4.4 to correctly compile and use the plugin. (technically it should also work with 4.3 right now, with slightly reduced functionality)
@pcman: thanks for the suggestions! I’ll give it a go with Xfce next week and see if we can improve things. Note that the gconf-related settings are only a temporary hack for this style in particular. The real place to fix this is during QApplication startup in 4.5 as these are not really style-specific settings. Note that we already read the XSettings in Qt, but for some reason the results are a bit off relative to GNOME apps still.
@Mildred: Make sure you did a ‘make install’. You also need to install or compile the qtconfig application and choose “GTK” as your Qt style. Alternatively you can start your application with ‘-style gtk’ as an argument.

Thanks for all the positive comments guys, it really motivates. I find some of the discussions about this project so far rather hilarious. This really was a creative friday project I initiated because I happen to use GNOME and it has bugged me personally for some time, being the pixel perfectionist I am. Oh and Trolltech actually pay us to do fun experiments like this like during work hours. πŸ˜‰

MontCook says:

GPL license only?

jens says:

MontCook: for now yes. It is quite likely to become a fully supported part of Qt. The released code is primarily for feedback and testing but I do not see any major problem in releasing it to commercial customers if there is sufficient demand for it.

blackcrack says:

finally get a qt to gtklook/style to the beautiful styles of GTK(2) sometimes finally to be able/can to use on QT !
Thank you very very mutch ! .. I hope it will be quite/fast add in Mandriva rpmbase ! *jump!!*
eeehhmmm, ad please, Developers, dont forget the deKorator !!
Please make this possible too to use these themes of deKorator.
There shold be not deletet, it is give so manny in
best regards

Alinaki says:

Cool! Works perfectly with DJL, Skype etc. But don’t work with opera 9.5 qt4-static build πŸ™

Rob Taylor says:

Jens, I love you. Can I have your babies?

I think this takes us closer to seeing developers making toolkit decisions based on what works best for them (in whatever language they want to use), rather than which desktop they use πŸ™‚

While this solves the ‘look’ part of look&feel, there is still a ‘feel’ part to be fixed. Due to differing HIGs between toolkits i doubt this will ever fully happen. Identical looks is a good step in decoupling application choice from the toolkit, but as long as i still have to think about the order of ‘Ok’ and ‘Cancel’ buttons in an application it won’t be “the real deal”.

jens says:

@rob: Thanks! I’m afraid one of us would have to perform some rather extensive surgery and I’m not ready to commit at that level yet. πŸ˜‰
@pieter: Nothing in the GNOME HIG prevents you from already using Qt as your toolkit of choice. Feel free to look it up at . The dialog button issue was solved with QDialogButtonBox in Qt 4.2. GTK uses GtkMessageBox to solve the same issue. My goal is that a well designed cross-platform Qt application will look completely at home in GNOME, and I am certain we can make that happen.

This is great, I mean REALLY great. I mean like REALLY REALLY great.

Now all you need to do is be able to use Gtk stock icons, and Gtk named icons…

That would be the best thing I’ve ever seen….

Now go on… Tottle off and make me REALLY REALLY REALLY happy. πŸ™‚

Andreas says:

40 comments??? Come on guys, a little more and Jens will blow away Lars’ post !

Join in and help Jens beat Lars’ record!

Jens, GtkStyle rocks!!

Thomas Zander says:

I just realized that KOffice just got ‘native’ look in Windows, Mac, KDE and Gnome. With zero effort on their part!
And to think it took OOo various years to get it to kinda run on the Mac! πŸ˜›

Jens says:

@karl: I’m glad you like it! We already provide a fair amount of the Gtk stock icons through QStyle. I’m looking into extending this for future versions of Qt but the main problem is actually providing the same feature on mac and windows.
andreas: That made me feel about as embarrassed as having my mother cheer for me during a soccer game. But you are right, I need more babies! πŸ™‚

At last! I’ve been waiting for this for *years*. Thanks Jens! Great work!

jb says:

I have tested this style against the development version of VLC (using Qt4.4) and you can see the results here:

Thanks for this good work.

jens says:

@Alinaki: It cannot work for static builds. You will have to wait for Opera to release a shared build or for the style to become part of Qt.
@jb: Cool! Note that in Qt 4.4 we also added some standard icons for media playback. πŸ™‚

gnuton says:

I’ve tryed this plugin on my Nokia N810 with Qt4-x11 4.4.0.
I’ve activated the GTK plugin via qtconfig, and now my Qt4 apps using CleanLooks instead of the maemo theme.
When I launch a Qt4 apps via XTerm i’ve a lot of “GtkStyle requires a 24-bit display” πŸ™
Is there a way to use maemo themes in our qt4 application?
Thank you

jens says:

@gnuton: That warning is only temporary. At least 16-bit displays will be supported. I added a bug ID for it so you can track it :

gnuton says:

thank you.

Vadim P. says:

Thank you, finally Qt’s native integration… integrates in gtk.

Lapino says:

Nice! I always avoided installing KDE/QT apps because something like this didn’t exist.

I did however notice some problems with the Elegant Brit theme (and other themes that change text color on hover).

Example: the menubar is normally dark with white text. When a menu item is active, it becomes white with dark text.
With this style, I get dark with dark text and white with white text.
Same goes for buttons that change background color when hovered.

Don’t know if this is a problem with the gtk theme or this one, but if this could get fixed, it would be great!

Mark Czubin says:

You’re my new hero. I develop solely with Qt but I’m a gnome user(sorry kde).
And while Qt apps look great on mac/windows, not so much on gnome. Hope this gets stable soon πŸ™‚

Thomas Zander says:

As far as I know the software is already quite stable. No crashes have been reported and very little issues registered ( ).

kinto says:

Can’t wait to try this! i think efforts like this are very useful for the free-desktop world! Thank you!

@gnuton: 16-bit (and any other depths) should be working now. But you would probably need to tweak fonts and layouts to blend in.
@lapino: I did some menu bar fixes so you can probably see the menu bar text now. I know it’s still not perfect at picking up custom palettes yet though.

leslie says:

I have a problem, when i try to install:

[- compile log removed -]

@leslie: You are using Qt3 to compile it. You need at least Qt 4.3. There are more complete installation instructions on the labs page.

Anders Bergh says:

I just compiled QGtkStyle on PowerPC (big endian) Linux (Arch Linux), however it doesn’t seem to work properly:

1. It wouldn’t compile, because of SE_TabBar etc around line 3002. I commented those cases out.

2. The colors etc are very wrong, I have a screenshot:

The respective package versions:

gtk2 2.12.9-2
qt 4.4.0-1

Hope this helps.

(btw, I couldn’t read the captcha. it’d be nice if it was a little bit more human-friendly)

@anders: Both issues should be resolved now. I prefer the bug tracker for things like this so lets continue the discussion there.

Gil says:

This is awesome, I’ve been waiting for something like this for a loooong time! πŸ™‚
Thank you so much!

Commenting closed.

Get started today with Qt Download now