Uniform look for Qt and GTK applications
Qt and GTK+ based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the "look and feel" differ significantly. This article will help you make your Qt and GTK+ applications look similar for a more streamlined and integrated desktop experience.
- 1 Overview
- 2 Theme engines
- 3 Styles for both Qt and GTK+
- 4 Tips and tricks
- 5 Troubleshooting
To get a similar look between the toolkits, you will most likely have to modify the following:
- Theme: The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.
- Style: The graphical layout and look of the widget set.
- Icon Theme: A set of global icons.
- Color Theme: A set of global colors that are used in conjunction with the style.
You can choose various approaches:
- Use a special theme engine, which intermediates the modification of the other graphical toolkit to match your main toolkit.
- Modify GTK+ and Qt styles separately with the tools listed below for each toolkit and aim for choosing similarly looking themes (style, colors, icons, cursors, fonts).
A theme engine can be thought of as a thin layer API which translates themes (excluding icons) between one or more toolkits. These engines add some extra code in the process and it is arguable that this kind of a solution is not as elegant and optimal as using native styles.
This Qt style uses GTK+ 2 to render all components to blend in with GNOME and similar GTK+ based environments. Beginning with Qt 4.5, this style is included in Qt. It requires to be installed and configured.
This is the default Qt4 style in Cinnamon, GNOME and Xfce, and the default Qt5 style in Cinnamon, GNOME, MATE, LXDE and Xfce. In other environments:
- For Qt4, it can be enabled with Qt Configuration (
qtconfig-qt4), choose GTK+ under Appearance > GUI Style. Alternatively, edit the
... [Qt] style=GTK+ ...
- For Qt 5, it can be enabled by setting the following environment variable:
For full uniformity, make sure that the configured GTK+ theme supports both GTK+ 2 and GTK+ 3.
Styles for both Qt and GTK+
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK+, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.
Breeze is the default Qt style of Plasma 5. It can be installed with thepackage for Qt5, and the package for Qt4. Similar GTK+ 2 and GTK+ 3 themes:
- Orion is a modern light theme for Gnome, can be installed with the package. It is the GTK+ theme used on the Kubuntu live CD (15.04) for GTK+ applications on Plasma 5.
- Gnome-breeze is a GTK+ theme built to match Breeze, can be installed with the AUR package.
Tips and tricks
KDE file dialogs for GTK+ applications
kgtk-wrapperdirectly and using the GTK+ 2.x binary as an argument:
$ /usr/bin/kgtk-wrapper gimp
- Modifying the KDE .desktop shortcuts files you can find at
/usr/share/applications/to prefix the
Execstatement with kgtk-wrapper.
- e.g. with GIMP, edit the
/usr/share/applications/gimp.desktopshortcut file and replace
Exec=kgtk-wrapper gimp-2.8 %U.
Using a GTK+ icon theme in Qt apps
If you are not using GNOME, run
gconf-editor, look under desktop > gnome > interface for the
icon_theme key and change it to your preference. As you are not using GNOME, it is possible that you will have to set
export DESKTOP_SESSION=gnome somewhere in your
~/.xinitrc or, if you are using LightDM, in
Improve subpixel rendering of GTK apps under KDE Plasma
Qt applications do not use QGtkStyle
Qt will not apply QGtkStyle correctly if GTK+ is using the GTK+-Qt Engine. Qt determines whether the GTK+-Qt Engine is in use by reading the GTK+ configuration files listed in the environmental variable
GTK2_RC_FILES. If the environmental variable is not set properly, Qt assumes you are using the engine, sets QGtkStyle to use the style GTK+ style Clearlooks, and outputs an error message:
QGtkStyle cannot be used together with the GTK_Qt engine.
Another error you may get after launching
qtconfig-qt4 from a shell and selecting the GTK+ style is:
QGtkStyle was unable to detect the current GTK+ theme.
According to this thread, you may simply have to install to solve this issue. This has the added benefit that you do not need to edit a file every time you change your theme via a graphical tool, like the one provided by xfce.
Users of Openbox and other non-GNOME environments may encounter this problem. To solve this, first add the following to your
... export GTK2_RC_FILES="$HOME/.gtkrc-2.0" ...
- Make sure to add this line before invoking the window manager.
- You can add multiple paths by separating them with colons.
- Make sure to use
~as it will not properly expand to the user's home directory.
Then specify the theme you want in the
~/.gtkrc-2.0 file using a dedicated application or manually, by adding:
... gtk-theme-name="[name of theme]" ...
Some tools only insert the following include directive in
... include "/usr/share/themes/SomeTheme/gtk-2.0/gtkrc" ...
which apparently is not recognized by all versions of QGtkStyle. You can hotfix this problem by inserting the
gtk-theme-name manually in your
~/.gtkrc-2.0 file like above.
~/.gtkrc-2.0file the next time you change themes.
If these steps do not work, installand run this command:
gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme [name of theme]
If you further want to set the same icon and cursor theme, then you have to specify them, too.
gconftool-2 --set --type string /desktop/gnome/interface/icon_theme Faenza-Dark
This sets the icon theme to Faenza-Dark located in
/usr/share/icons/Faenza-Dark. For the cursor theme you first have to set the gconf value.
gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme Adwaita
Then you will have to create the file
/usr/share/icons/default/index.theme with the following lines:
[Icon Theme] Inherits=Adwaita
Themes not working in GTK+ apps
If the style or theme engine you set up is not showing in your GTK applications then it is likely your GTK+ settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..
$ export | grep gtk
Usually the expected files should be
~/.gtkrc for GTK1 and
~/.gtkrc2.0-kde for GTK+ 2.x.
Newer versions of
~/.gtkrc2.0-kde and set the export variable in
If you recently removed gtk-qt-engine and are trying to set a GTK+ theme then you must also remove
~/.kde/env/gtk-qt-engine.rc.sh and reboot. Doing this will ensure that GTK+ looks for its settings in the standard
~/.gtkrc2.0 instead of the