Ubuntu – Qt apps stopped inheriting GTK themes

15.10gnomegtkqtthemes

After a fresh installation of Ubuntu Gnome 15.10, Qt apps like qpdfview or QuiteRSS suddenly stopped inheriting the global GTK theme, in my case Numix. The same is also true for the default Adwaita theme, so most likely it's not the theme's fault. It seems, that these apps always use the Cleanlooks Qt theme, regardless of the present GTK theme.

I've never had any problems with theming on previous installations of Ubuntu Gnome.

Installing qt4-qtconfig and playing with different settings (GUI style: default, cleanlooks or gtk+) didn't have any effect on these apps.

Curiously, the qt4-qtconfig app itself is themed properly. So after selecting a different theme, e.g. "desktop settings (default)" or "windows", the theme of this app changes, but not in qpdfview or QuiteRSS. The trick with installing libgnomeui-0 (mentioned here) didn't help either.

Does anyone experience the same and know of a workaround?

Best Answer

On Ubuntu 17.10 Qt4 apps do inherit the global GTK theme, while Qt5 don't. Since libqt5libqgtk2 isn't available in the official Ubuntu repositories anymore, we have to use another workaround:

Install qt5-style-plugins from the Ubuntu repositories with sudo apt install qt5-style-plugins.

Then add export QT_QPA_PLATFORMTHEME=gtk2 to ~/.profile by echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile. This will theme all apps started as user.

If you prefer to apply the theming system-wide (for user and root apps), then use sudo sh -c "echo 'export QT_QPA_PLATFORMTHEME=gtk2' >> /etc/environment".

For Ubuntu 20.04+ you have to sudo apt install appmenu-gtk2-module, so that qt apps don't start with a delay.

I prefer this method over using kvantum, because with this method also root apps are themed properly and you don't have to adjust the theme in the kvantum manager, to match it your gtk theme.

Reboot and enjoy!

Related Question