How can I get Qt5 applications to use the GTK theme in Ubuntu 17.04?
The look and feel of Qt5 applications is determined by platform themes and styles. The platform theme is responsible for icons, fonts, etc. and the style controls how widgets are rendered. I think you'll find your application such as Qt Creator is using the GTK3 platform theme as standard.
The problem has occurred since Qt5.7. In this release, the GTK2 platform theme and style was removed and replaced with the GTK3 platform theme. I've recently been in discussion with the Qt developers and it appears there isn't a GTK3 style to complement the platform theme and there are currently no plans to implement this in the future. Therefore, on Ubuntu, the default style is "Fusion" using the GTK3 platform theme.
There are a couple of methods to add a native style as follows:
- The old GTK2 platform theme and style are still available in a separate package called
qtstyleplugins
that can be downloaded here. Unfortunately, the GTK2 style is not compatible with the GTK3 platform theme. If you want to use the GTK2 style you will have to use the GTK2 platform theme. This will mean your dialogs etc. do not look native in Ubuntu 17.04. However, you may prefer it to "Fusion". - You didn't state what desktop environment you are using. There is a third party platform theme and style called
QGnomePlatform
available here andadwaita-qt
available here. This provides a fully native look and feel when using Ubuntu Gnome.
For Qt Creator, I'm not 100% sure if it uses global theme/style locations. You may have to install them in {Qt_installation_folder}\Tools\QtCreator\lib\Qt\Plugins\platformthemes\
and {Qt_installation_folder}\Tools\QtCreator\lib\Qt\Plugins\styles\
.
Apart from qt5ct
you also need to install qt5-style-plugins
package, then you should get the 'gtk2' theme in qt5ct
sudo apt-get install qt5-style-plugins
And, as per the qt5ct documentation, don't forget to set QT_QPA_PLATFORMTHEME=qt5ct
in /etc/X11/Xsession.d/56xubuntu-session
and/or /etc/environment