Qt apps stopped inheriting GTK themes

7,570

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 – 20.10 you have to sudo apt install appmenu-gtk2-module, so that qt apps don't start with a delay. In Ubuntu 21.04 you don't have to install appmenu-gtk2-module any more.

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!

Share:
7,570

Related videos on Youtube

DMT
Author by

DMT

Updated on September 18, 2022

Comments

  • DMT
    DMT over 1 year

    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?

    • Admin
      Admin about 8 years
      These might be Qt5 apps. Try installing libqt5libqgtk2 as suggested here.
  • Serge Stroobandt
    Serge Stroobandt over 7 years
    Excellent!!! Xubuntu LTS should install this library by default!
  • Fibbs
    Fibbs over 5 years
    This fixed the issue for me in Xubuntu 18.04.1
  • pktiuk
    pktiuk almost 4 years
    This solution is not recommended on newer systems: github.com/pop-os/pop/issues/712
  • Enterprise
    Enterprise over 3 years
    Be sure to restart after installing appmenu-gtk2-module.