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

From ArchWiki
Jump to: navigation, search
(oxygen-gtk)
(26 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:Desktop environments (English)]]
+
[[Category:Desktop environments]]
[[Category:Eye candy (English)]]
+
[[Category:Eye candy]]
{{i18n|Uniform Look for QT and GTK Applications}}
+
[[es:Uniform Look for Qt and GTK Applications]]
 
+
[[it:Uniform Look for Qt and GTK Applications]]
 +
[[ru:Uniform Look for Qt and GTK Applications]]
 +
[[uk:Uniform Look for Qt and GTK Applications]]
 +
[[zh-CN:Uniform Look for Qt and GTK Applications]]
 
{{Article summary start}}
 
{{Article summary start}}
{{Article summary text|This articles details theme configuration of GTK+ at QT applications to ensure a uniform style. This article will cover configuration, theme engines, tricks and troubleshooting.}}
+
{{Article summary text|This articles details theme configuration of GTK+ at Qt applications to ensure a uniform style. This article will cover configuration, theme engines, tricks and troubleshooting.}}
 
{{Article summary heading|Related}}
 
{{Article summary heading|Related}}
 
{{Article summary wiki|GTK+}}
 
{{Article summary wiki|GTK+}}
Line 10: Line 13:
 
{{Article summary end}}
 
{{Article summary end}}
  
[[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.
+
[[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.
  
*'''Theme''' - Collection of a style, an icon theme and a colour theme.
+
To get a similar look between the two you will most likely have to modify the following:
*'''Style''' - Graphical layout; look.
+
* '''Theme''': The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.
*'''Icon Theme''' - Set of global icons.
+
* '''Style''': The graphical layout and look of the widget set.
*'''Colour Theme''' - Set of global colours that are used in conjunction with the style.
+
* '''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:
 
You can choose various approaches:
  
* Modify [[Uniform Look for QT and GTK Applications#Styles for both Qt and GTK+|GTK+ and Qt styles]] separately with the tools listed below for each toolkit and aim for choosing similarly looking themes (style, colours, icons, cursors, fonts).
+
* Modify [[Uniform Look for QT and GTK Applications#Styles for both Qt and GTK+|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 [[Uniform Look for QT and GTK Applications#Theme Engines|theme engine]], which intermediates the modification of the other graphical toolkit to match your main toolkit:
 
* Use a special [[Uniform Look for QT and GTK Applications#Theme Engines|theme engine]], which intermediates the modification of the other graphical toolkit to match your main toolkit:
** if you work in KDE 4 desktop environment then there is available a GTK-Qt engine, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;
+
** if you work in KDE 4 desktop environment then a GTK-Qt engine is available, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;
** if you work in other desktop environments, you can choose QGtkStyle engine (built in Qt), which forces Qt apps to use your GTK+ 2.x theme.
+
** 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+#GTK+ 3.x|GTK+ 3.x]] wiki article to find out how to make it look similar to GTK+ 2.x themes.
 
Should you use also GTK+ 3.x toolkit, follow the [[GTK+#GTK+ 3.x|GTK+ 3.x]] wiki article to find out how to make it look similar to GTK+ 2.x themes.
Line 32: Line 36:
 
=== KDE4 Oxygen ===
 
=== KDE4 Oxygen ===
  
[http://www.oxygen-icons.org/ Oxygen] is the QT4 style that installs with KDE4.
+
[http://www.oxygen-icons.org/ Oxygen] is a Qt style that comes by default with KDE4. There are various ways of mimicking its appearance that are discribed below.
  
 
==== oxygen-gtk ====
 
==== oxygen-gtk ====
A couple of GTK+ ports are available in the {{Pkg|oxygen-gtk}} packages. Their primary goal is to ensure visual consistency between GTK2/GTK3 and qt-based applications running under kde. Secondary objectives are to also have stand-alone, nice looking gtk themes that behave well on other Desktop Environments. Unlike other attempts made to port the kde oxygen theme to gtk, these attempts do not depend on Qt (via some Qt to Gtk conversion engine), nor do they render widget appearances via hard coded pixmaps, which otherwise break everytime some setting is changed in kde.  
+
[http://kde-look.org/content/show.php/?content=136216 oxygen-gtk] is a port of the Oxygen Qt Style to GTK+ done by the Oxygen developers. Unlike other attempts, it is a native GTK+ style that does not depend on Qt (via some Qt to GTK+ conversion engine) nor does it render widget appearances via hard coded pixmaps. The style has the primary goal to ensure visual consistency between GTK+ 2.x/3.x and Qt-based applications running under KDE with a secondary objective to also have a standalone, nice looking GTK+ theme that behaves well in other desktop environments.
  
  pacman -S oxygen-gtk2 oxygen-gtk3
+
The style has GTK+ 2.x and GTK+ 3.x variants which can be [[Pacman|installed]] with the {{Pkg|oxygen-gtk2}} or {{Pkg|oxygen-gtk3}} packages, available in the [[official repositories]].
  
=====Automatic procedure=====
+
{{Note|Before KDE 4.10, you needed to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}}, or let it automatically create like described below. But that is actually counter-productive with KDE 4.10’s oxygen-gtk, and you should delete this file after upgrading to prevent it from messing with your colors. Cleanup-removal of {{ic|~/.kde4/share/config/gtkrc}} might be necessary, too}}
To change the GTK theme a few applications are available:
+
  pacman -S gtk-kde4
+
  pacman -S gtk-chtheme
+
  pacman -S gtk-theme-switch2
+
  pacman -S lxappearance
+
  
Then change the theme of your choice in the respective application:
+
===== Automatic procedure =====
gtk-kde4 ("System Settings > Lost and Found > GTK style")
+
A few [[#GTK2 styles|dedicated applications]] are available in the official repositories that are able to change the GTK+ theme.
gtk-chtheme
+
gtk-theme-switch2
+
lxappearance
+
  
You can also install {{AUR|chakra-gtk-config}}. After install it can be found in '''System Settings > Application Appearance > GTK Config'''.
+
You can also install {{AUR|kde-gtk-config}} from [[AUR]]. After installation, it can be found in ''System Settings > Application Appearance > GTK Configuration''. It allows you to configure the look and feel for both GTK+ 2.x and GTK+ 3.x applications and is integrated with the KDE add-on installer (Get Hot New Stuff), so you can also download and install other GTK+ themes.
 
+
=====Manually procedure=====
+
To manually change the GTK theme to {{Pkg|oxygen-gtk}} , you need to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}} with the following content:
+
  
 +
===== Manual procedure =====
 +
To manually change the GTK+ theme to '''oxygen-gtk''', you need to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}} with the following content:
 +
{{hc|~/.kde4/share/config/gtkrc-2.0|<nowiki>
 
  include "/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrc"
 
  include "/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrc"
 
  include "~/.themes/oxygen-gtk/gtk-2.0/gtkrc"
 
  include "~/.themes/oxygen-gtk/gtk-2.0/gtkrc"
 +
 
  style "user"
 
  style "user"
 
  {  
 
  {  
fg[NORMAL] = "#1b1918"
+
    fg[NORMAL] = "#1b1918"
bg[NORMAL] = "#d5d1cf"
+
    bg[NORMAL] = "#d5d1cf"
text[NORMAL] = "#181615"
+
    text[NORMAL] = "#181615"
base[NORMAL] = "#ffffff"
+
    base[NORMAL] = "#ffffff"
fg[ACTIVE] = "#1b1918"
+
    fg[ACTIVE] = "#1b1918"
bg[ACTIVE] = "#d5d1cf"
+
    bg[ACTIVE] = "#d5d1cf"
text[ACTIVE] = "#181615"
+
    text[ACTIVE] = "#181615"
base[ACTIVE] = "#ffffff"
+
    base[ACTIVE] = "#ffffff"
fg[PRELIGHT] = "#1b1918"
+
    fg[PRELIGHT] = "#1b1918"
bg[PRELIGHT] = "#d5d1cf"
+
    bg[PRELIGHT] = "#d5d1cf"
text[PRELIGHT] = "#ffffff"
+
    text[PRELIGHT] = "#ffffff"
base[PRELIGHT] = "#43ace8"
+
    base[PRELIGHT] = "#43ace8"
fg[SELECTED] = "#1b1918"
+
    fg[SELECTED] = "#1b1918"
bg[SELECTED] = "#d5d1cf"
+
    bg[SELECTED] = "#d5d1cf"
text[SELECTED] = "#ffffff"
+
    text[SELECTED] = "#ffffff"
base[SELECTED] = "#43ace8"
+
    base[SELECTED] = "#43ace8"
fg[INSENSITIVE] = "#8d8a88"
+
    fg[INSENSITIVE] = "#8d8a88"
bg[INSENSITIVE] = "#ccc7c5"
+
    bg[INSENSITIVE] = "#ccc7c5"
text[INSENSITIVE] = "#a6a5a5"
+
    text[INSENSITIVE] = "#a6a5a5"
base[INSENSITIVE] = "#f4f4f4"
+
    base[INSENSITIVE] = "#f4f4f4"
GtkTreeView::odd_row_color="#ffffff"
+
    GtkTreeView::odd_row_color="#ffffff"
GtkTreeView::even_row_color="#f8f7f6"
+
    GtkTreeView::even_row_color="#f8f7f6"
 
  }
 
  }
 +
 
  widget_class "*" style "user"
 
  widget_class "*" style "user"
 +
 
  style "tooltips"
 
  style "tooltips"
 
  {  
 
  {  
bg[NORMAL] = "#bedfff"
+
    bg[NORMAL] = "#bedfff"
fg[NORMAL] = "#252321"
+
    fg[NORMAL] = "#252321"
 
  }
 
  }
 +
 
  widget "gtk-tooltips" style "tooltips"
 
  widget "gtk-tooltips" style "tooltips"
 
  #gtk-theme-name="qt4"
 
  #gtk-theme-name="qt4"
Line 95: Line 95:
 
  gtk-icon-theme-name="gk4ico"
 
  gtk-icon-theme-name="gk4ico"
 
  gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-button=22,22:gtk-large-toolbar=22,22"
 
  gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-button=22,22:gtk-large-toolbar=22,22"
 +
</nowiki>
 +
}}
  
 
Then you need to create the symbolic link {{ic|~/.kde4/share/config/gtkrc}}:
 
Then you need to create the symbolic link {{ic|~/.kde4/share/config/gtkrc}}:
 
  ln -s ~/.kde4/share/config/gtkrc-2.0 ~/.kde4/share/config/gtkrc
 
  ln -s ~/.kde4/share/config/gtkrc-2.0 ~/.kde4/share/config/gtkrc
  
==== Oxygen Icons ====
+
==== Oxygen icons ====
If you are using Oxygen icons and want a consistent look in GTK open/save dialogs, you can install an [https://aur.archlinux.org/packages.php?O=0&K=oxygenrefit2-icon-theme&do_Search=Go oxygenrefit2] icon theme from AUR and set it as your GTK icon theme. Add the theme to the {{ic|~/.gtkrc-2.0}} file or you can use lxappearance and set it.
+
If you are using Oxygen icons and want a consistent look in GTK+ dialogs, you can install the {{AUR|oxygenrefit2-icon-theme}} icon theme from [[AUR]] and set it as your GTK+ icon theme. To apply the theme you can use {{ic|lxappearance}} (or a similar program) or set it manually by adding the following line to {{ic|~/.kde4/share/config/gtkrc-2.0}}:
 
  gtk-icon-theme-name="OxygenRefit2"
 
  gtk-icon-theme-name="OxygenRefit2"
There are also a couple GTK themes built on the [https://aur.archlinux.org/packages.php?ID=24329 gtk-kde42-oxygen-theme Oxygen style] that can also do this.
+
 
 +
Another version of the Oxygen icon theme for GTK+ applications can be installed with the {{AUR|oxygen-gtk-icons}} package from [[AUR]].
  
 
=== QtCurve ===
 
=== QtCurve ===
  
Available for ''qt4'' (kde4), ''qt3'' (kde3), and ''gtk2'' (gnome) in the '''[extra]''' repository, this highly-configurable style is the most popular all-rounder. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders. You can install all of them using pacman.
+
QtCurve is a highly popular and configurable set of widget styles for Qt4/KDE4, KDE3 and GTK+ 2.x. QtCurve can be installed with the packages {{Pkg|qtcurve-kde4}}, {{Pkg|qtcurve-kde3}} or {{Pkg|qtcurve-gtk2}}, all available in the official repositories. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders.
# pacman -S qtcurve-gtk2 qtcurve-kde3 qtcurve-kde4
+
  
To manually change the GTK theme to '''QtCurve''', you need to create the file {{ic|~/.gtkrc-2.0-kde4}} with the following content:
+
To manually change the GTK+ theme to '''QtCurve''', you need to create the file {{ic|~/.gtkrc-2.0-kde4}} with the following content:
 
  include "/usr/share/themes/QtCurve/gtk-2.0/gtkrc"
 
  include "/usr/share/themes/QtCurve/gtk-2.0/gtkrc"
 
  include "/etc/gtk-2.0/gtkrc"
 
  include "/etc/gtk-2.0/gtkrc"
Line 119: Line 121:
 
  widget_class "*" style "user-font"  
 
  widget_class "*" style "user-font"  
 
  gtk-theme-name="QtCurve"
 
  gtk-theme-name="QtCurve"
 +
 
Then you need to create the symbolic link {{ic|~/.gtkrc-2.0}}:
 
Then you need to create the symbolic link {{ic|~/.gtkrc-2.0}}:
 
  ln -s .gtkrc-2.0-kde4 .gtkrc-2.0
 
  ln -s .gtkrc-2.0-kde4 .gtkrc-2.0
Line 126: Line 129:
 
=== Others ===
 
=== Others ===
  
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. Below is a list:
+
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. {{AUR|kdestyle-klearlook}} for Qt4/KDE4 and the Clearlooks GTK+ theme).
  
*klearlooks (qt3); clearlooks (gtk2)
+
== Changing styles in each toolkit ==
 
+
== How do I set styles for each toolkit? ==
+
  
 
You can use the following methods to change the theme used in each environment.
 
You can use the following methods to change the theme used in each environment.
  
=== QT3 styles ===
+
=== Qt3 styles ===
* Using ''KDE3 Control Center'' (kcontrol):
+
Qt3 styles can be changed in the following ways:
:--> Appearance & Themes --> Style --> Widget Style
+
* using the ''KDE3 Control Center'' (kcontrol), the settings can be found in ''Appearance & Themes > Style > Widget Style''.
* kde-config --style [name of style]
+
* using the command-line tool {{ic|kde-config --style [name of style]}}.
* ''Qt Configuration'' (qt3config | /opt/qt/bin/qtconfig)
+
* using the default ''Qt Configuration'' (qt3config) application, the settings can be found in ''Appearance > Select GUI Style''.
:--> Appearance --> Select GUI Style
+
  
=== QT4 styles ===
+
=== Qt4 styles ===
* Using ''KDE4 System Settings'' (/usr/bin/systemsettings)
+
Qt4 styles cand be changed in a similar way:
:--> Common Appearance and Behavior --> Application Appearance --> Style --> Widget Style''
+
* using the ''KDE4 System Settings'' (systemsettings), the settings can be found in ''Common Appearance and Behavior > Application Appearance > Style > Widget Style''
* ''Qt Configuration'' (/usr/bin/qtconfig)
+
* using the command-line tool {{ic|kwriteconfig --file kdeglobals --group General --key widgetStyle [name of style]}}.
:--> Appearance --> Select GUI Style
+
* using the ''Qt Configuration'' (qtconfig) application, the settings can be found in ''Appearance > Select GUI Style''.
  
Note that while Qt Configuration allows you to choose the theme, font, etc. for the Qt apps, you can modify more settings with KDE 4 System Settings - e.g. font antialiasing and hinting.
+
Note that while Qt Configuration allows you to choose the theme, font, etc. for Qt apps, you can modify more settings with KDE4 System Settings (e.g. font antialiasing and hinting).
  
 
=== GTK2 styles ===
 
=== GTK2 styles ===
* {{Pkg|gtk-kde4}}    (allows you to change style and font of GTK applications in KDE4)
+
Various applications and methods are available to change the GTK+ 2.x styles:
* {{Pkg|lxappearance}} (a DE independent configuration tool from the LXDE project, which does not require any other parts of LXDE)
+
* {{App|gtk-kde4|An application that allows you to change style and font of GTK+ applications in KDE4.|http://kde-look.org/content/show.php?content&#61;74689|{{Pkg|gtk-kde4}}}}
* {{Pkg|gtk-chtheme}} (considered a better alternative to switch2)
+
{{Note|After installation, {{ic|gtk-kde4}} can also be found in ''System Settings > Lost and Found > GTK style''.}}
* {{Pkg|gtk2_prefs}}
+
* {{App|LXAppearance|A desktop independent GTK+ style configuration tool from the LXDE project (it does not require other parts of the LXDE desktop).|http://wiki.lxde.org/en/LXAppearance|{{Pkg|lxappearance}}}}
* {{Pkg|gtk-theme-switch2}}
+
* {{App|GTK+ Change Theme|A little program that lets you change your GTK+ 2.0 theme (considered a better alternative to ''switch2'').|http://plasmasturm.org/code/gtk-chtheme/|{{Pkg|gtk-chtheme}}}}
* [[GTK%2B#GTK.2B_2.x|Manual configuration]]
+
* {{App|GTK+ Preference Tool|A GTK+ theme selector and font switcher.|http://gtk-win.sourceforge.net/home/index.php/Main/GTKPreferenceTool|{{Pkg|gtk2_prefs}}}}
 +
* {{App|GTK+ Theme Switch|A simple GTK+ theme switcher.|http://muhri.net/nav.php3?node&#61;gts|{{Pkg|gtk-theme-switch2}}}}
 +
* For manual configuration see the [[GTK%2B#GTK.2B_2.x|GTK+ page]].
  
 
=== GTK1 styles ===
 
=== GTK1 styles ===
* [https://aur.archlinux.org/packages.php?K=gtk-theme-switch gtk-theme-switch package (AUR)]
+
To change GTK1 styles you can install the {{AUR|gtk-theme-switch}} package from the [[AUR]].
  
 
== Theme Engines ==
 
== 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.
 
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 ===
+
=== GTK+-Qt Engine ===
  
This one is for use by GTK+ applications running in KDE, which basically means this does not work in other desktop environments. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plug-ins directly. Please note that there are rendering issues with some Qt styles.
+
This one is for use by GTK+ applications running in KDE, which basically means this does not work in other desktop environments. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plugins directly. This engine can be installed with the {{Pkg|gtk-qt-engine}} package, available in the official repositories.
  
# pacman -S gtk-qt-engine
+
{{Note|There are rendering issues with some Qt styles.}}
  
You can access it from:
+
You can access it from the ''KDE System Settings'' under ''Lost and Found > GTK Styles and Fonts''.
:''Control Center (kcontrol) --> Appearance & Themes --> GTK Styles and Fonts''
+
  
If you want to remove it entirely and every trace of it, you should delete the following files:
+
If you want to remove the engine entirely you need to uninstall it and also delete the following files:
 +
$ rm ~/.gtkrc2.0-kde
 +
$ rm ~/.kde4/env/gtk-qt-engine.rc.sh
 +
$ rm ~/gtk-qt-engine.rc
  
*~/.gtkrc2.0-kde
+
=== QGtkStyle ===
*~/.kde4/env/gtk-qt-engine.rc.sh
+
*~/gtk-qt-engine.rc
+
  
==== Make it work with OpenOffice ====
+
This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK+ to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. To enable this style, use:
Set (as root):
+
* ''Qt Configuration'': choose "GTK+" under ''Appearance > GUI Style''.
export SAL_GTK_USE_PIXMAPPAINT=1
+
* ''KDE4 System Settings'': choose "GTK+ Style" under ''Application Appearance > Style > Applications''.
into /etc/profile. In KDE4 systemsettings, make sure "use my KDE style in GTK applications" is selected in Appearance > GTK styles and fonts.
+
* the command-line: edit the {{ic|.config/Trolltech.conf}} file by adding:
  
=== Making Qt apps use GTK+ themes ===
+
{{hc|~/.config/Trolltech.conf|<nowiki>
You can do this easily using the Qt configuration tool, 'qtconfig', but you must make sure you have installed 'libgnomeui', even if you don't use Gnome.
+
...
 +
[Qt]
 +
style=GTK+
 +
...</nowiki>}}
  
==== QGtkStyle ====
+
{{Note|Beginning with version 4.5 this style is included in Qt and does not require a separate package anymore.}}
  
This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. To enable this style, use Qt Configuration or KDE 4 System Settings (see above) and choose "GTK+" style.
+
== Tips and tricks ==
 +
=== KDE file dialogs for GTK+ apps ===
 +
[http://kde-apps.org/content/show.php?content&#61;36077 KGtk] is a wrapper script that uses LD_PRELOAD to force KDE file dialogs (open, save, etc.) in GTK+ 2.x apps. If you use KDE and prefer its file dialogs over GTK+'s then you can install {{AUR|kgtk}} from the [[AUR]] (a KDE3 version is also available in the {{AUR|kde3-kgtk}} package). Once installed you can run GTK+ 2.x applications with {{ic|kgtk-wrapper}} in two ways (using [[Gimp]] in the examples):
 +
* Calling {{ic|kgtk-wrapper}} directly and using the GTK+ 2.x binary as an argument:
 +
/usr/bin/kgtk-wrapper gimp
 +
* Creating a symbolic link to {{ic|kgtk}} using the name of the GTK+ 2.x binary:
 +
ln -s /usr/bin/kgtk-wrapper /usr/local/bin/gimp
 +
:To run the version of Gimp with KDE dialogs, make sure you have {{ic|/usr/local/bin/}} before {{ic|/usr/bin/}} in your {{ic|PATH}}.
 +
{{Note|Some GTK+ applications may not be compatible with KGtk.}}
  
{{Note|Beginning with version 4.5 this style is included in Qt and does not require a separate package anymore.}}
+
=== aMSN with GTK+ or KDE dialogs ===
 +
aMSN's uses the Tk toolkit for its user interface. To make it use GTK+ or KDE dialogs install the {{AUR|amsn-plugins-desktopintegration}} plugin available in the [[AUR]]. Other plugins can be found on [http://www.amsn-project.net/plugins.php aMSN's Plugin Page].
  
====Having trouble making your Qt applications use QGtkStyle?====
+
=== Run an application with a specific theme ===
 +
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
  
Qt won't apply QGtkStyle correctly if GTK is using the [[Uniform Look for QT and GTK Applications#GTK-QT-Engine|GTK-QT-Engine]]. Qt determines whether the [[Uniform Look for QT and GTK Applications#GTK-QT-Engine|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 [[Uniform Look for QT and GTK Applications#GTK-QT-Engine|GTK-QT-Engine]], sets QGtkStyle to use the style GTK style ''Clearlooks'', and outputs an error message:
+
This will launch Firefox with the QtCurve theme.
 +
 
 +
=== Using a GTK+ icon theme in Qt apps ===
 +
If you are not using GNOME, run {{ic|gconf-editor}}, look under ''desktop > gnome > interface'' for the {{ic|icon_theme}} key and change it to your preference.
 +
 
 +
=== Improve subpixel rendering of GTK apps under KDE ===
 +
If the subpixel rendering in GTK apps is not as sharp as in native KDE Qt applications, try to add the following lines to your {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}} (between the {{ic|<fontconfig>}} tags):
 +
 
 +
{{bc|<nowiki>
 +
<match target="font">
 +
    <edit mode="assign" name="lcdfilter">
 +
        <const>lcddefault</const>
 +
    </edit>
 +
</match>
 +
</nowiki>}}
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== 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 {{ic|/etc/profile}} (as root):
 +
export SAL_GTK_USE_PIXMAPPAINT=1
 +
 
 +
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|GTK+-Qt Engine]]. Qt determines whether the GTK+-Qt Engine is in use by reading the GTK+ configuration files listed in the environmental variable {{ic|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.
 
  QGtkStyle cannot be used together with the GTK_Qt engine.
  
Another error you may get after launching qtconfig from a shell and selecting the Gtk+ style is:
+
Another error you may get after launching {{ic|qtconfig}} from a shell and selecting the GTK+ style is:
  
 
  QGtkStyle was unable to detect the current GTK+ theme.
 
  QGtkStyle was unable to detect the current GTK+ theme.
  
Users of [[Openbox]] and other non-GNOME environments may encounter this problem. Here is a solution:
+
Users of [[Openbox]] and other non-GNOME environments may encounter this problem. To solve this, first add the following to your {{ic|.xinitrc}} file:
 
+
{{hc|.xinitrc|<nowiki>
*Tell Qt where to look for your GTK configuration file by adding the following to your {{ic|.xinitrc}} file:
+
...
**Add this line before invoking the window manager.
+
**To add multiple paths, separate them with colons.
+
**The $HOME part will expand to be path to your user's home directory. Using the ~ shortcut won't work.
+
{{hc|.xinitrc|2=...
+
 
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
 
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
...}}
+
...
 +
</nowiki>}}
  
*In {{ic|.gtkrc-2.0}} you must specify a GTK theme. For example:
+
{{Note|
**This is usually done for you by an [[Uniform Look for QT and GTK Applications#GTK2_styles|application which sets GTK2 Styles]]
+
* Make sure to add this line before invoking the window manager.
**If {{ic|~/.gtkrc-2.0}} doesn't exist, simply create it and insert the following line.
+
* You can add multiple paths by separating them with colons.
{{hc|.gtkrc-2.0|2=...
+
* Make sure to use {{ic|$HOME}} instead of {{ic|~}} as it will not properly expand to the user's home directory.
gtk-theme-name="Crux"
+
}}
...}}
+
However it seems in some cases those tools insert only an include directive like
+
{{hc|.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 like above, note however that Gtk2-style-change applications might overwrite that change when you use them.
+
  
If these steps do not work, install gconf and run this command:
+
Then specify the theme you want in the {{ic|~/.gtkrc-2.0}} file using a [[#GTK2 styles|dedicated application]] or manually, by adding:
 +
{{hc|.gtkrc-2.0|<nowiki>
 +
...
 +
gtk-theme-name="[name of theme]"
 +
...
 +
</nowiki>}}
  
gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme '''your-theme-name'''
+
Some tools only insert the following include directive in {{ic|~/.gtkrc-2.0}}:
 +
{{hc|.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 {{ic|gtk-theme-name}} manually in your {{ic|~/.gtkrc-2.0}} file like above.
  
To choose your GTK theme for QT apps you must run:
+
{{Note|Style-changing applications will most probably rewrite the {{ic|~/.gtkrc-2.0}} file the next time you change themes.}}
  
qtconfig
+
If these steps do not work, install {{Pkg|gconf}} and run this command:
  
== Other Tricks ==
+
  gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme [name of theme]
=== KDE file dialogs for GTK2 apps ===
+
KGtk is a wrapper script that LD_PRELOAD to force KDE file dialogs (open, save, etc) in GTK2 apps. If you use KDE and prefer its file dialogs over GTK's then you can install kgtk from AUR. Once installed you can run GTK2 applications with kgtk-wrapper in 2 ways (using gimp in the examples).
+
  
Calling kgtk-wrapper directly and using the GTK2 binary as an arguement
+
According to [https://bbs.archlinux.org/viewtopic.php?id&#61;99175&p&#61;1 this thread], you may simply have to install {{Pkg|libgnomeui}} to solve this issue.
/usr/bin/kgtk-wrapper gimp
+
  
OR
+
If you further want to set the same icon and cursor theme, then you have to specify them, too.
  
Creating a symbolic link to kgtk using the name of the GTK2 binary. Then you can run /usr/bin/gimp when you want to run gimp with KDE dialogs.
+
  gconftool-2 --set --type string /desktop/gnome/interface/icon_theme Faenza-Dark
ln -s /usr/bin/kgtk-wrapper /usr/local/bin/gimp
+
/usr/local/bin/gimp
+
  
=== aMSN GTK or KDE dialogs ===
+
This sets the icon theme to Faenza-Dark located in {{ic|/usr/share/icons/Faenza-Dark}}. For the cursor theme you first have to set the gconf value.
aMSN's TK file dialogs are plain looking but no fear there is a plugin that will allow you to use GTK or KDE file dialogs to match your desktop.  You can find the plugin on [http://www.amsn-project.net/plugins.php aMSN's Plugin Page]
+
  
=== Using custom GTK style ===
+
gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme Adwaita
You can use custom styles for specific GTK2 applications. For this, use GTK2_RC_FILES=/path/to/theme/gtk-2.0/gtkrc appname
+
  
For example:
+
Then you will have to create the file {{ic|/usr/share/icons/default/index.theme}} with the following lines:
GTK2_RC_FILES=/usr/share/themes/QtCurve/gtk-2.0/gtkrc firefox
+
It will launch firefox with QtCurve theme.
+
  
=== Using gtk icon theme in Qt apps ===
+
[Icon Theme]
If you don't using Gnome run gconf-editor and edit that setting to your icon theme name
+
  Inherits=Adwaita
  /desktop/gnome/interface/icon_theme
+
 
+
== Troubleshooting ==
+
  
=== Themes not working in GTK apps ===
+
=== Themes not working in GTK+ apps ===
  
If the style or theme engine you setup isn't showing in your GTK apps then it's likely your GTK settings files aren't being loaded for some reason. You can check where your system expects to find these files by doing the following..
+
If the style or theme engine you set up is not showing in your GTK applications then it's 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
 
  $ export | grep gtk
  
Usually the expected files should be ~/.gtkrc for GTK1, ~/.gtkrc2.0 or ~/.gtkrc2.0-kde for GTK2
+
Usually the expected files should be {{ic|~/.gtkrc}} for GTK1 and {{ic|~/.gtkrc2.0}} or {{ic|~/.gtkrc2.0-kde}} for GTK+ 2.x.
  
Newer versions of gtk-qt-engine use ~/.gtkrc2.0-kde and set the export variable in ~/.kde/env/gtk-qt-engine.rc.sh
+
Newer versions of {{pkg|gtk-qt-engine}} use {{ic|~/.gtkrc2.0-kde}} and set the export variable in {{ic|~/.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 remove ~/.kde/env/gtk-qt-engine.rc.sh and reboot. Doing this will ensure that GTK looks for it's settings in the standard ~/.gtkrc2.0 instead of ~/.gtkrc2.0-kde
+
If you recently removed '''gtk-qt-engine''' and are trying to set a GTK+ theme then you must also remove {{ic|~/.kde/env/gtk-qt-engine.rc.sh}} and reboot. Doing this will ensure that GTK+ looks for it's settings in the standard {{ic|~/.gtkrc2.0}} instead of the {{ic|~/.gtkrc2.0-kde}} file.

Revision as of 12:18, 9 February 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

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 4 desktop environment then a GTK-Qt engine is available, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;
    • 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.

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.

KDE4 Oxygen

Oxygen is a Qt style that comes by default with KDE4. There are various ways of mimicking its appearance that are discribed below.

oxygen-gtk

oxygen-gtk is a port of the Oxygen Qt Style to GTK+ done by the Oxygen developers. Unlike other attempts, it is a native GTK+ style that does not depend on Qt (via some Qt to GTK+ conversion engine) nor does it render widget appearances via hard coded pixmaps. The style has the primary goal to ensure visual consistency between GTK+ 2.x/3.x and Qt-based applications running under KDE with a secondary objective to also have a standalone, nice looking GTK+ theme that behaves well in other desktop environments.

The style has GTK+ 2.x and GTK+ 3.x variants which can be installed with the oxygen-gtk2 or oxygen-gtk3 packages, available in the official repositories.

Note: Before KDE 4.10, you needed to create the file ~/.kde4/share/config/gtkrc-2.0, or let it automatically create like described below. But that is actually counter-productive with KDE 4.10’s oxygen-gtk, and you should delete this file after upgrading to prevent it from messing with your colors. Cleanup-removal of ~/.kde4/share/config/gtkrc might be necessary, too
Automatic procedure

A few dedicated applications are available in the official repositories that are able to change the GTK+ theme.

You can also install kde-gtk-configAUR from AUR. After installation, it can be found in System Settings > Application Appearance > GTK Configuration. It allows you to configure the look and feel for both GTK+ 2.x and GTK+ 3.x applications and is integrated with the KDE add-on installer (Get Hot New Stuff), so you can also download and install other GTK+ themes.

Manual procedure

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

~/.kde4/share/config/gtkrc-2.0
 include "/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrc"
 include "~/.themes/oxygen-gtk/gtk-2.0/gtkrc"

 style "user"
 { 
    fg[NORMAL] = "#1b1918"
    bg[NORMAL] = "#d5d1cf"
    text[NORMAL] = "#181615"
    base[NORMAL] = "#ffffff"
    fg[ACTIVE] = "#1b1918"
    bg[ACTIVE] = "#d5d1cf"
    text[ACTIVE] = "#181615"
    base[ACTIVE] = "#ffffff"
    fg[PRELIGHT] = "#1b1918"
    bg[PRELIGHT] = "#d5d1cf"
    text[PRELIGHT] = "#ffffff"
    base[PRELIGHT] = "#43ace8"
    fg[SELECTED] = "#1b1918"
    bg[SELECTED] = "#d5d1cf"
    text[SELECTED] = "#ffffff"
    base[SELECTED] = "#43ace8"
    fg[INSENSITIVE] = "#8d8a88"
    bg[INSENSITIVE] = "#ccc7c5"
    text[INSENSITIVE] = "#a6a5a5"
    base[INSENSITIVE] = "#f4f4f4"
    GtkTreeView::odd_row_color="#ffffff"
    GtkTreeView::even_row_color="#f8f7f6"
 }

 widget_class "*" style "user"

 style "tooltips"
 { 
    bg[NORMAL] = "#bedfff"
    fg[NORMAL] = "#252321"
 }

 widget "gtk-tooltips" style "tooltips"
 #gtk-theme-name="qt4"
 gtk-font-name="Sans Serif 9"
 gtk-icon-theme-name="gk4ico"
 gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-button=22,22:gtk-large-toolbar=22,22"

Then you need to create the symbolic link ~/.kde4/share/config/gtkrc:

ln -s ~/.kde4/share/config/gtkrc-2.0 ~/.kde4/share/config/gtkrc

Oxygen icons

If you are using Oxygen icons and want a consistent look in GTK+ dialogs, you can install the oxygenrefit2-icon-themeAUR icon theme from AUR and set it as your GTK+ icon theme. To apply the theme you can use lxappearance (or a similar program) or set it manually by adding the following line to ~/.kde4/share/config/gtkrc-2.0:

gtk-icon-theme-name="OxygenRefit2"

Another version of the Oxygen icon theme for GTK+ applications can be installed with the oxygen-gtk-iconsAUR package from AUR.

QtCurve

QtCurve is a highly popular and configurable set of widget styles for Qt4/KDE4, KDE3 and GTK+ 2.x. QtCurve can be installed with the packages qtcurve-kde4, qtcurve-kde3 or qtcurve-gtk2, all 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" 
gtk-theme-name="QtCurve"

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"

Others

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

Changing styles in each toolkit

You can use the following methods to change the theme used in each environment.

Qt3 styles

Qt3 styles can be changed in the following ways:

  • using the KDE3 Control Center (kcontrol), the settings can be found in Appearance & Themes > Style > Widget Style.
  • using the command-line tool kde-config --style [name of style].
  • using the default Qt Configuration (qt3config) application, the settings can be found in Appearance > Select GUI Style.

Qt4 styles

Qt4 styles cand be changed in a similar way:

  • using the KDE4 System Settings (systemsettings), the settings can be found in Common Appearance and Behavior > Application Appearance > Style > Widget Style
  • using the command-line tool kwriteconfig --file kdeglobals --group General --key widgetStyle [name of style].
  • using the Qt Configuration (qtconfig) application, the settings can be found in Appearance > Select GUI Style.

Note that while Qt Configuration allows you to choose the theme, font, etc. for Qt apps, you can modify more settings with KDE4 System Settings (e.g. font antialiasing and hinting).

GTK2 styles

Various applications and methods are available to change the GTK+ 2.x styles:

  • gtk-kde4 — An application that allows you to change style and font of GTK+ applications in KDE4.
http://kde-look.org/content/show.php?content=74689 || gtk-kde4
Note: After installation, gtk-kde4 can also be found in System Settings > Lost and Found > GTK style.
  • LXAppearance — A desktop independent GTK+ style configuration tool from the LXDE project (it does not require other parts of the LXDE desktop).
http://wiki.lxde.org/en/LXAppearance || lxappearance
  • GTK+ Change Theme — A little program that lets you change your GTK+ 2.0 theme (considered a better alternative to switch2).
http://plasmasturm.org/code/gtk-chtheme/ || gtk-chtheme
  • GTK+ Preference Tool — A GTK+ theme selector and font switcher.
http://gtk-win.sourceforge.net/home/index.php/Main/GTKPreferenceTool || gtk2_prefs
  • GTK+ Theme Switch — A simple GTK+ theme switcher.
http://muhri.net/nav.php3?node=gts || gtk-theme-switch2

GTK1 styles

To change GTK1 styles you can install the gtk-theme-switchAUR package from the AUR.

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.

GTK+-Qt Engine

This one is for use by GTK+ applications running in KDE, which basically means this does not work in other desktop environments. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plugins directly. This engine can be installed with the gtk-qt-engine package, available in the official repositories.

Note: There are rendering issues with some Qt styles.

You can access it from the KDE System Settings under Lost and Found > GTK Styles and Fonts.

If you want to remove the engine entirely you need to uninstall it and also delete the following files:

$ rm ~/.gtkrc2.0-kde
$ rm ~/.kde4/env/gtk-qt-engine.rc.sh
$ rm ~/gtk-qt-engine.rc

QGtkStyle

This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK+ to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. To enable this style, use:

  • Qt Configuration: choose "GTK+" under Appearance > GUI Style.
  • KDE4 System Settings: choose "GTK+ Style" under Application Appearance > Style > Applications.
  • the command-line: edit the .config/Trolltech.conf file by adding:
~/.config/Trolltech.conf
...
[Qt]
style=GTK+
...
Note: Beginning with version 4.5 this style is included in Qt and does not require a separate package anymore.

Tips and tricks

KDE file dialogs for GTK+ apps

KGtk is a wrapper script that uses LD_PRELOAD to force KDE file dialogs (open, save, etc.) in GTK+ 2.x apps. If you use KDE and prefer its file dialogs over GTK+'s then you can install kgtkAUR from the AUR (a KDE3 version is also available in the kde3-kgtkAUR package). 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
  • Creating a symbolic link to kgtk using the name of the GTK+ 2.x binary:
ln -s /usr/bin/kgtk-wrapper /usr/local/bin/gimp
To run the version of Gimp with KDE dialogs, make sure you have /usr/local/bin/ before /usr/bin/ in your PATH.
Note: Some GTK+ applications may not be compatible with KGtk.

aMSN with GTK+ or KDE dialogs

aMSN's uses the Tk toolkit for its user interface. To make it use GTK+ or KDE dialogs install the amsn-plugins-desktopintegrationAUR plugin available in the AUR. Other plugins can be found on aMSN's Plugin Page.

Run an application with a specific theme

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.

Improve subpixel rendering of GTK apps under KDE

If the subpixel rendering in GTK apps is not as sharp as in native KDE Qt applications, try to add the following lines to your $XDG_CONFIG_HOME/fontconfig/fonts.conf (between the <fontconfig> tags):

<match target="font">
    <edit mode="assign" name="lcdfilter">
        <const>lcddefault</const>
    </edit>
</match>

Troubleshooting

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):

export SAL_GTK_USE_PIXMAPPAINT=1

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 from a shell and selecting the GTK+ style is:

QGtkStyle was unable to detect the current GTK+ theme.

Users of Openbox and other non-GNOME environments may encounter this problem. To solve this, first add the following to your .xinitrc file:

.xinitrc
...
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
...
Note:
  • 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:

.gtkrc-2.0
...
gtk-theme-name="[name of theme]"
...

Some tools only insert the following include directive in ~/.gtkrc-2.0:

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

According to this thread, you may simply have to install libgnomeui to solve this issue.

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's 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-engine 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 it's settings in the standard ~/.gtkrc2.0 instead of the ~/.gtkrc2.0-kde file.