Get Qt5 Apps To Use Native Gtk+ Style In Ubuntu 18.04 LTS

Some Qt5 applications don't use a Gtk+ style by default in Gnome (in Ubuntu 18.04 for example), which makes them look out of place. This includes applications like VirtualBox, VLC, qBittorrent, Simple Screen Recoder, the ownCloud desktop client, and so on.

This article explains how to fix this and get Qt5 applications to use a Gtk+ 2 style in Ubuntu.

VLC and VirtualBox before and after using the tweak in this article:

  • Before:

VirtualBox qt5 ugly Ubuntu 18.04

vlc qt5 ugly Ubuntu 18.04

  • After:

VirtualBox qt5 gtk+ style Ubuntu 18.04

vlc qt5 gtk+ style Ubuntu 18.04


To fix this issue and get Qt5 applications to use a Gtk+ style, all you have to do is follow the simple steps below.

1. Install qt5-style-plugins, a package which contains Cleanlooks, Motif, Plastique, and Gtk+ 2 Qt5 styles.

sudo apt install qt5-style-plugins

2. Set Qt5 applications to use the Gtk+ 2 style by adding export QT_QPA_PLATFORMTHEME=gtk2 to your ~/.profile. To do this with a simple command, run the following:

echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile

3. Log out after installing this package.

After logging back in, Qt5 applications like qBittorrent, VLC, or Virtualbox should use a Gtk+ style on your Gnome desktop in Ubuntu 18.04.

It's important to note that this solves the issue for applications installed via apt / deb. This tweak does not work for applications installed using Snap, Flatpak, or AppImage packages. At least that was the case on my Ubuntu 18.04 desktop.

6 comments:

  1. After installing qt5-style-plugins, you could also install qt5ct which is a gui to set the Gtk+ 2 style and many other styles.

    ReplyDelete
    Replies
    1. Indeed, but this should be enough to un-uglify the applications 🙂. Also, qt5ct affects (at least a did a while back) some app's fuctionality, like breaking the tray icon for the ownCloud desktop client.

      Delete
  2. Hi, is there a way to apply it in ElementaryOS? The QT apps i.e. Virtualbox, or MKVToolnix looks ugly

    ReplyDelete
    Replies
    1. Have you tried this in elementary? It might work but I did not try it. If it doesn't work, you can give qt5ct a try: https://sourceforge.net/projects/qt5ct/ It has a PPA too (it's in Ubuntu Bionic but not in older versions).

      Delete
  3. Didn't work in eOS. Is it because Elementary Loki is based in Ubuntu 16.04?

    ReplyDelete
    Replies
    1. I don't think it's because it uses Ubuntu 16.04, that version has the qt5-style-plugins package. Maybe elementary OS somehow disables this.

      Delete

Powered by Blogger.