Use Custom Themes For Qt Applications (And Fix Qt5 Theme On GNOME) On Linux With Kvantum
Some Qt applications look out of place in Gnome (and other Gtk-based desktop environments). 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 |
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 / Yaru, 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, Yaru / Communitheme and the default Gnome (Adwaita) theme:
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.
On Fedora you can install Kvantum from the repositories, using:
sudo dnf install kvantum
Arch Linux / Manjaro users can install Kvantum with:
sudo pacman -S kvantum-qt5
Solus OS has Kvantum in its repositories too, and you can install it using:
sudo eopkg install kvantum
Pop!_OS / Ubuntu 21.04, 20.10, 20.04, 19.10 and 19.04 / Linux Mint 20.* / Debian Buster and newer: Starting with Ubuntu 19.04 (Disco Dingo) / Debian Buster, Kvantum is available in the official Ubuntu repositories. So if you use Pop!_OS / Ubuntu 21.04, 20.10, 20.04, 19.10, 19.04, or Debian Buster and newer, you can install Kvantum from the repositories using:
sudo apt install qt5-style-kvantum qt5-style-kvantum-themes
Pop!_OS / Ubuntu 18.04 and Linux Mint 19.* (as well as other Ubuntu-based Linux distributions, like Elementary OS 5) users wanting an easy way of installing Kvantum can use a PPA. The PPA also has newer Kvantum packages for Ubuntu 20.10, 20.04, 19.10 or 19.04 too. Add it and install Kvantum using:
sudo add-apt-repository ppa:papirus/papirus
sudo apt update
sudo apt install qt5-style-kvantum qt5-style-kvantum-themes
You may also build Kvantum from source. To install the latest Kvantum from source in Debian, Ubuntu or Linux Mint (any version), you can compile it from source. To do this, follow the steps below.
Step 1: Download the latest Kvantum source
You can either download the latest Kvantum release, or grab the latest Kvantum code via Git:
git clone https://github.com/tsujan/Kvantum
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 libkf5windowsystem-dev
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.Get Qt5 applications to use Kvantum
No matter the way you've installed Kvantum, to be able to use it on 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
If Kvantum was installed from the repositories, simply remove it using your Linux distribution's package manager.
No matter the Kvantum installation method, 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.