Make Qt use the GTK Style on XFCE or Xubuntu

I’m a Qt developer and use Xubuntu in my Linux VMs as it is lighter than KDE and doesn’t get in my way (unlike Unity).

By default there is a problem with QGtkStyle which stops it correctly picking up the GTK theme as XFCE does not save it in the usual place.

To fix this we can use a simple script:

#!/bin/sh
DEFAULT_XFCE_THEME=greybird
XFCE_THEME=$(xfconf-query -c xsettings -p /Net/ThemeName 2>/dev/null)
GTK2_RC_FILES=$HOME/.config/xfce4/gtkrc
[ -z "$XFCE_THEME" ] && XFCE_THEME=$DEFAULT_XFCE_THEME
echo gtk-theme-name = $XFCE_THEME > $GTK2_RC_FILES
unset DEFAULT_XFCE_THEME
unset XFCE_THEME
export GTK2_RC_FILES
. /etc/xdg/xfce4/xinitrc

Put this script into $HOME/.config/xfce4/xinitrc and ensure it is executable by running chmod +x $HOME/.config/xfce4/xinitrc.

abc says:

The problem appears because /desktop/gnome/interface is missing in gconf.
Installing the package libgnome2-common will fix it.

Yes, Qt only looks for the Gnome path by default. This guide avoids having to install (large amounts of ) Gnome dependencies to have Qt applications under XFCE look good.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>