15

Since I updated to Ubuntu 17.04, Qt5 applications (such as Qt Creator) won't use the GTK theme anymore. I tried to change this using qt5ct, but it only has the styles Fusion and Windows available, even though that the package qt5-gtk-platformtheme is installed.

How can this be fixed?

Edit: I'm using Unity.

8

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:

  1. 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".
  2. You didn't state what desktop environment you are using. There is a third party platform theme and style called QGnomePlatform available here and adwaita-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\.

5
  • Thanks for the detailed explanation. I wouldn't mind Fusion so much if the font rendering would not be so horrible. Is there an open bug somewhere about this? Apr 29 '17 at 14:25
  • The fonts have not appeared poor from what I've seen on my system. Do you have a screenshot of this?
    – gsxruk
    Apr 29 '17 at 15:27
  • I've uploaded a screenshot here: imgur.com/a/u34W6 Left is Qt Creator, right is a vim session in gnome-terminal. I agree that is very subtle, but the Qt fonts just feel blurry (or blurrier?) to me. Both applications are set to Ubuntu Mono 12. Apr 29 '17 at 17:58
  • I see what you mean, but I agree it's subtle. Sorry, don't know what to suggest on that one.
    – gsxruk
    Apr 29 '17 at 19:09
  • In case you are interested: I've had better results with infinality on funtoo, but as far as I know this patchset isn't properly maintained anymore. Anyway, the fonts look much better on my laptop, which has an IPS panel, so maybe I just need to upgrade my 7 year old display on my desktop. Thanks for your help! Apr 29 '17 at 20:05
7

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

5
  • This answer works for me, without installing qt5ct.
    – DMT
    Dec 11 '17 at 11:47
  • 1
    yes, installing only qt5-style-plugins (i.e. w/o qt5ct) works just fine for styling qt5.7+ with gtk2. qt5ct is only needed if you want to also use other styles for qt5.7+ than gtk2
    – Gyll
    Dec 12 '17 at 19:41
  • 1
    btw, being sick and tired of inconsistencies on my desktop, i ended up putting together a theme of my own, you might want to check it out if inconsistencies drive your nuts: xfce-evolution.sourceforge.net
    – Gyll
    Apr 28 '19 at 12:49
  • This however stops working when you try to use wayland. I set QT_QPA_PLATFORMTHEME=qt5ct and QT_QPA_PLATFORM=wayland in /etc/environment and I can then use qt5ct to change the default themes that come preinstalled with qt5ct. Then I install qt5ct-style-plugins and new theme i.e. gtk2 appears in qt5ct but it does not do anything when I select it!
    – 71GA
    Jul 2 at 7:38
  • 1
    SUCESS! After I installed lxappearance and choose the desired GTK2 theme (any that are inside /usr/share/themes) inside lxappearance , chosen theme was automatically adopted by qt5ct. This was the missing step! Well qt5ct did automatically adopt the theme even without lxappearance, but default theme was ugly! This also works for pyqt5 applications like convertall!
    – 71GA
    Jul 2 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.