Jens
Uncategorized
Qt
QGtkStyle
Styles/QGtkStyle
Posted by Jens
 in Uncategorized, Qt, QGtkStyle, Styles/QGtkStyle
 on Friday, February 13, 2009 @ 20:29

Qt already provides a set of standard icons. The nice thing about these icons is that they adapt to the current desktop environment. However the current selection of available icons is rather limited, at least compared to what KDE apps have at their disposal through the freedesktop icon specification. Since most of these icons only are available on the X11 platform, we still haven’t decided how to make them available to pure Qt applications such as Designer and Creator. While we are thinking about that, I thought I might as well wrap up the essential code and provide it as a simple convenience class, QtIconLoader, that you can use in your own project. You can find the source code here.

The class currently only provides one static function:

QIcon QtIconLoader::icon(const QString &iconName, const QIcon &fallback = QIcon()).

Usage should be fairly obvious:
new QAction(QtIconLoader::icon(”document-new”), tr(”&New”), this);

The fallback is of course for platform compatibility so you can provide your own masterpiece as a fallback for other platforms, which is probably the icon you are already using.

And since no blog post is complete without some eye candy, I modified our well know textedit example to QtIconLoader:

Here is how it looks running on KDE 4.2:
QTextEdit in KDE

And since we also pick up GNOME settings, this is how it looks when running GNOME:

QTextEdit in GNOME

I’m sure there are bugs. For some reason freedesktop standardized on everything except a convenient way to detect which theme to use, so we need to do some trickery to get to the KDE and GNOME settings. Feel free to report issues and suggestions here.

denis
QGtkStyle
Styles/QGtkStyle
Posted by denis
 in QGtkStyle, Styles/QGtkStyle
 on Thursday, October 02, 2008 @ 17:27

There are a lot of Qt styles that have been created by enthusiasts - QtCurve, Oxygen, Bespin and as latest addition to the library - QGtkStyle (excellent job, Jens!), which makes a bunch of Gtk themes available to Qt. But wait a second - all these styles are mainly used by Linux people! What about people suffering with Windows? Here is the answer - if you feel geek enough to compile Qt and the style yourself and if you want your application to look different (read: “beautiful”) - you can try the new QGtkStyle_win32 available on labs (it is a separate project for now):

svn://labs.trolltech.com/svn/styles/gtkstyle_win32

I’ve tested it with two Gtk theme engines - wimp (which is distributed with Gimp and emulates the WindowsXP style - yes, it is crazy to use the Gtk theme engine on WindowsXP through qgtkstyle to emulate WindowsXP theme ;). The second theme engine I’ve tried is murrine, which was quite easy to compile on Windows. It’s time for some screenshots:
gtkstyle_windows.png

WindowsXP style (the one that is deployed with Gimp)

browser demo with WindowsXP style through QGtkStyle and wimp theme engine.

You can even run the Perforce Visual Client with it! (however it crashes sometimes - looks like the perforce guys made some binary incompatible changes to the Qt libraries they ship with their app).

p4v.PNG

To try it out you will need a Gtk development package
You can either use Qt compiled with Visual C++ or MinGW, however in the latter case you need to recompile Qt with the “-mms-bitfields” compiler option to make it binary compatible with the Gtk libraries.
Afterwards just put your gtkstyle(d).dll in the plugin path (either %QTDIR%\plugins\styles or <application directory>\plugins\styles) and launch your application with the “-style gtk” command-line option. (and make sure you have both mingwm10.dll and gtk libraries in your system path!).
At this point you should be able to run Qt apps with the default Gtk theme, so the next step is to compile the murrine Gtk2 theme engine. For this step you need the patch to be able to compile murrine on Windows. Then just put the libmurrine.dll to the Gtk engines directory <gtk root>\lib\gtk-2.0\2.10.0\engines) and you are ready to use Murrine Themes!

P.S. of course native Gtk file dialogs are also available on Windows ;)

standarddialogs.PNG

Jens
Qt
Styles
QGtkStyle
Posted by Jens
 in Qt, Styles, QGtkStyle
 on Wednesday, October 01, 2008 @ 08:24

One of the few remaining complaints against Qt applications using QGtkStyle on GNOME have been about the file dialog. So far it certainly looked like a GTK+ dialog, but it was not exactly the same dialog that other applications had been using. While I’m not really in a position to comment on which dialog is the better one, this is what it currently looks like with QGtkStyle:

Gtk dialog with Qt

However, the policy on other platforms such as Windows and Mac OS X has been to use the native dialogs if possible. I recently applied some patches to support this for GTK+ as well. This is what you will see if you open forms in Designer now:

Gtk dialog with Qt

Note that since the KDE file dialog provides somewhat different functionality from the Qt one, KDE applications will still use the KDE file dialog. Feel free to try it out directly from the svn on my labs page and report whatever issues you might find here.

Jens
Uncategorized
Qt
Styles
QGtkStyle
Posted by Jens
 in Uncategorized, Qt, Styles, QGtkStyle
 on Friday, September 05, 2008 @ 14:14

QGtkStyle made it’s way into the Qt snapshots this week, meaning it will become part of the Qt 4.5 release. Technical users can already compile and use it on their own desktop, but once Qt 4.5 is out it will simply replace Cleanlooks as the default application style Qt uses on GNOME desktops. While I haven’t blogged about it since the announcement back in May, a lot of fixes and improvements have gone into it since then and I’d like to thank everybody contributing bug reports, suggestions and patches to the project so far. Since the existing plugin based on Qt 4.4 seems rather popular and not everybody feel comfortable using an unstable version of Qt, I will continue to maintain it as a separate project and accept bug reports over at my google code page.

Clearlooks dialogglider theme

In other news, the nice folks over at the Qt4 Maemo garage have been adapting QGtkStyle to work nicely with the Maemo platform as was evidenced by lorn’s post last month. Samuel also blogged about using Freetype for subpixel filtering which should eventually take care of any differences in font rendering between Qt and GTK.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.