Difference between revisions of "Uniform look for Qt and GTK applications"

From ArchWiki
Jump to navigation Jump to search
(Remove 'Changing styles in each toolkit' section. It was merged into GTK+ and Qt pages.)
(Theme engines: The GTK+-Qt engine is unmaintained, and won't support GTK+ 3, so remove it.)
Line 71: Line 71:
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.
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.
=== GTK+-Qt engine ===
* There are rendering issues with some Qt styles.
* There is no support for GTK+ 3.}}
This engine applies all Qt settings (styles, fonts, but not icons) to GTK+ applications, using style plugins directly. It can be installed with {{AUR|gtk-qt-engine}} from the [[AUR]].
You can access it from the ''KDE System Settings'' under ''Lost and Found > GTK Styles and Fonts'' or with {{ic|kcmshell4 kde-gtk-config}}.
To remove the engine, uninstall the package and delete the following files:
$ rm ~/.gtkrc2.0-kde
$ rm ~/.kde4/env/gtk-qt-engine.rc.sh
$ rm ~/gtk-qt-engine.rc
=== QGtkStyle ===
=== QGtkStyle ===

Revision as of 12:16, 1 July 2015

zh-CN: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.

To get a similar look between the two 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:

  • 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).
  • Use a special theme engine, which intermediates the modification of the other graphical toolkit to match your main toolkit:
    • if you work in KDE Plasma Desktop 4 environment then a GTK-Qt engine is available, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;
    • similarly if you work in the Trinity desktop environment a GTK-Qt and GTK3-Qt engine is available.
    • if you work in other desktop environments, you can choose the QGtkStyle engine (built in Qt), which forces Qt apps to use your GTK+ 2.x theme.

Should you use also GTK+ 3.x toolkit, follow the GTK+ 3.x wiki article to find out how to make it look similar to GTK+ 2.x themes.

Note: Local theme changes usually do not apply to applications run as root. See GTK+#Configuration programs.

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. Since version 3.16, GTK3 does not support non-CSS themes, hence previous solutions such as oxygen-gtk are no longer viable options.


QtCurve is a highly popular and configurable set of widget styles for GTK+ 2.x, Qt4, Qt5 and KDE4. QtCurve can be installed with the packages from qtcurveAUR group, available in the official repositories. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders.

To manually change the GTK+ theme to QtCurve, you need to create the file ~/.gtkrc-2.0-kde4 with the following content:

include "/usr/share/themes/QtCurve/gtk-2.0/gtkrc"
include "/etc/gtk-2.0/gtkrc"

style "user-font"
    font_name="Sans Serif"
widget_class "*" style "user-font" 

Then you need to create the symbolic link ~/.gtkrc-2.0:

ln -s .gtkrc-2.0-kde4 .gtkrc-2.0

If you want also specify a font, you can add (and adapt) the following line to the file:

 gtk-font-name="Sans Serif 9"


Breeze is the default Qt style of Plasma 5. To achieve a uniform look for both - Qt and GTK applications - GTK versions of the style can be installed with the gnome-breeze-gitAUR package.


Orion is compatible with GTK 3.6 and 3.8 and it also includes a GTK 2.0 theme using Murrine engine. Orion is the GTK theme used on the Kubuntu live CD (15.04) for GTK fallback on Plasma 5.

Orion can be installed with the gtk-theme-orion package. Since there is no Orion style for Qt, you need to use "GTK+" style (built in Qt) to apply Orion to Qt apps.


Similar style sets are those that look like each other - written and provided for both Qt and GTK+ - but are not necessarily from the same developers. You may have to do some minor tweaking to make them look the same (e.g. kdestyle-klearlookAUR for Qt4/KDE4 and the Clearlooks GTK+ theme).

Theme engines

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.


Warning: Depending on GTK theme, this style may cause rendering issues such as transparent fonts or inconsistent widgets.

This Qt style uses GTK+ to render all components to blend in with GNOME and similar GTK+ based environments. It requires at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. Beginning with Qt 4.5, this style is included in Qt.

To enable it with qtconfig-qt4, choose GTK+ under Appearance > GUI Style. In KDE4 System Settings, choose GTK+ Style under Application Appearance > Style > Applications.

Alternatively, edit the ~/.config/Trolltech.conf file:


Tips and tricks

KDE file dialogs for GTK+ applications

Warning: Some GTK+ applications may not be compatible with KGtk-wrapper (e.g. Chromium), sometimes the wrapper makes the application crash (e.g. Firefox) and even other applications like KDM (when used with e.g. Thunderbird).

kgtkAUR from the AUR is a wrapper script which uses LD_PRELOAD to force KDE file dialogs in GTK+ 2.x apps. Once installed you can run GTK+ 2.x applications with kgtk-wrapper in two ways (using Gimp in the examples):

  • Calling kgtk-wrapper directly 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 Exec statement with kgtk-wrapper.
e.g. with GIMP, edit the /usr/share/applications/gimp.desktop shortcut file and replace Exec=gimp-2.8 %U by Exec=kgtk-wrapper gimp-2.8 %U.

Run an application with a specific theme

Merge-arrows-2.pngThis article or section is a candidate for merging with GTK+.Merge-arrows-2.png

Notes: General GTK+ tip (Discuss in Talk:Uniform look for Qt and GTK applications#)

You can use custom styles for specific GTK+ 2.x applications. To run an application with a specific theme use:

GTK2_RC_FILES=/usr/share/themes/QtCurve/gtk-2.0/gtkrc firefox

This will launch Firefox with the QtCurve theme.

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 /etc/environment.

Improve subpixel rendering of GTK apps under KDE Plasma

See Font configuration#LCD filter.


gtk-qt-engine does not work with OpenOffice

To make OpenOffice respect the Qt theme chosen with the GTK+-Qt Engine you need to add the following line to /etc/profile (as root):


Also make sure to select "Use my KDE style in GTK applications" in KDE4 System Settings under Lost and Found > GTK Styles and Fonts.

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 libgnomeui 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 .xinitrc file:

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 $HOME instead of ~ 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 ~/.gtkrc-2.0:

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.

Note: Style-changing applications will most probably rewrite the ~/.gtkrc-2.0 file the next time you change themes.

If these steps do not work, install gconf and 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]

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 or ~/.gtkrc2.0-kde for GTK+ 2.x.

Newer versions of gtk-qt-engineAUR use ~/.gtkrc2.0-kde and set the export variable in ~/.kde/env/gtk-qt-engine.rc.sh. 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 ~/.gtkrc2.0-kde file.