Uniform style for Qt apps on Ubuntu
While trying out ghostwriter, an alternative markdown editor, on Ubuntu 22.04 it was starkly noticeable that the application’s menu bar was using a light theme while the OS was set to dark theme. This is not unexpected since this is a Qt app from the KDE desktop ecosystem running on Ubuntu with Gnome desktop environment.
The solution to this styling issue is to manual specify a theme for all Qt apps and this can be best achieved with Kvantum with the custom KvYaru-Colours theme.
Install Kvantum via apt:
apt install qt5-style-kvantum qt5-style-kvantum-themes
To ensure the Kvantum themes are applied to Qt apps we need to specify an override environment variable e.g.
QT_STYLE_OVERRIDE=kvantum ghostwriter
To permanently set this style override export it in your shell profile:
echo "export QT_STYLE_OVERRIDE=kvantum" >> ~/.profile
The default themes that come with Kvantum don’t quite match that of Ubuntu Yaru, there is a KvYaru theme but no dark variant and KvGnomeDark has blue colour hinting that doesn’t match the default orange hinting for Yaru. This can be resolved by downloading the theme KvYaru-Colours and installing to the default theme location for Kvantum; ~/.config/kvantum
.
Open Kvantum and navigate to Change/Delete theme, select KvYaru-BaseDark followed by clicking Use this theme to activate it and when reopening Qt apps the styling should now match Gtk apps.
References: