Use Custom Themes For Qt Applications On Linux With Kvantum

Kvantum Qt style app

Some Qt applications look out of place in Gnome (and other Gtk-based desktop environments). If all you want is to get Qt5 applications to look decent on your Linux desktop, you can use the QT_QPA_PLATFORMTHEME=gtk2 export tweak we mentioned a couple of weeks ago.

To be able to choose the theme Qt applications are using on your Linux system, tweak some settings, and have an overall better integration with Gnome / Gtk, you can give Kvantum a try. This is a SVG-based theme engine for both Qt4 and Qt5, KDE and LXQt.

Using it, you'll not only be able to theme Qt4 and Qt5 software to match your current Gtk theme almost entirely (as long as your current Gtk theme has a Kvantum theme available), but also configure some Qt theme-related settings.

The idea behind Kvantum - to use SVG images to style Qt widgets - comes from QuantumStyle, which is not developed any more, but is continued as QSvgStyle. I find QSvgStyle more difficult to use than Kvantum though, because it only comes with one built-in theme.

kvantum active theme configuration settings
Kvantum active theme configuration

kvantum active theme configuration settings
Kvantum active theme configuration

Besides allowing you to change the Qt 4 and Qt 5 style, Kvantum also features:

  • built-in Kvantum themes such as Adapta (and Dark), Ambiance, Ark (and Dark variant), Ubuntu Communitheme, Gnome, Oxygen, Simplicity, and others (in total there are 30 themes)
  • allows installing extra Kvantum themes
  • configure active theme: set the toolbar button style, change UI icons and button sizes, enable or disable composite effects or translucent windows, option to respect dark themes, completely remove icons from menus, and much more
  • assign themes to specific applications
  • a preview tool, somewhat similar to the gtk3-widget-factory tool, is available so you can see the current Kvantum theme and your modifications in action

Here's Kvantum with some popular themes like Ambiance, Communitheme and the default Gnome (Adwaita) theme:

Kvantum Ambiance

Kvantum Communitheme

Kvantum Gnome Adwaita

It's important to mention that Kvantum and other similar tools cannot change the Qt theme for applications installed from Snap, Flatpak or AppImage binaries.

Installing and using Kvantum



You can find the Kvantum installation instructions for some Linux distributions here.

For Debian / Ubuntu / Linux Mint, there are deb binaries available to download but for a quite old version (Kvantum 0.10.5, released back in October, 2017).

To install the latest Kvantum in Debian, Ubuntu or Linux Mint, you can compile it from source. To do this, follow the steps below.

Step 1: Download the latest Kvantum source

While the latest source available on the Kvantum releases page is version 0.10.6, there's a newer Kvantum version available, released today. Since the source is not yet available on the releases page, you can get it by grabbing the latest Kvantum code via Git. Use either of these, as the instructions below should work with any of them, or at least it worked for me in Ubuntu 18.04.

Step 2: Install the build dependencies

sudo apt install g++ cmake libx11-dev libxext-dev qtbase5-dev libqt5svg5-dev libqt5x11extras5-dev libqt4-dev qttools5-dev-tools

Step 3: Compile Kvantum

Navigate to the folder where you extracted the Kvantum source (or cloned the Git repository) from a terminal (using cd /path/to/folder) and compile the application using these commands:

mkdir build && cd build
cmake ..
make

Step 4: Install Kvantum

To install Kvantum, run the following command (while in the same folder):

sudo make install

This builds and installs Kvantum for Qt 5, which should be enough since most applications use Qt 5 nowadays. If you want to build it for Qt4, use the same instructions as above but add -DENABLE_QT4=ON after the cmake .. command from step 3.

Step 5: Get Qt applications to use Kvantum

For Gtk-based desktops, you'll need to export QT_STYLE_OVERRIDE=kvantum. You can add this to your ~/.profile by running the command below:

echo "export QT_STYLE_OVERRIDE=kvantum" >> ~/.profile

After this, logout and log back in. To apply Kvantum system-wide, and not just for your user, you could add export QT_STYLE_OVERRIDE=kvantum in /etc/environment instead of ~/.profile.

For desktop environments such as KDE and LXQt, using Kvantum is a lot easier - select Kvantum under Widget Style and Color Scheme and that's all.

Now all you have to do is run Kvantum and select the theme you want to use, and tweak the settings to suit your needs.

How to completely remove Kvantum


If you want to uninstall Kvantum installed from source, start by opening a terminal, navigating to the folder where you've extracted (in the build folder from the Kvantum/Kvantum directory if you've followed our instructions) and built the source - e.g. cd Kvantum/Kvantum/build, and running this command:

sudo make uninstall

You'll also need to remove the export QT_STYLE_OVERRIDE=kvantum line from your ~/.profile file. To do this, open ~/.profile with a text editor, e.g. Gedit:

gedit ~/.profile

And remove the QT_STYLE_OVERRIDE=kvantum line from this file, then save it, logout and log back in.

2 comments:

  1. I'm using Ubuntu 18.04. It really works!! Thank you for your good post!

    ReplyDelete