This simple tutorial shows how to make Qt-based applications automatically change their theme to be light or dark, according to system color style in Ubuntu 22.04.
Ubuntu has global option to change system color scheme to light or dark since 22.04. However, Qt apps (e.g., VirtualBox, qBittorrent, keepassxc) always stick to their own color style, except for the title-bar.
To make Qt applications fit into GNOME environment as well as possible, Fedora Linux is working on some projects to do the job.
So far, QGnomePlatform theme is a good choice, though the upstream has been switching to QAdwaitaDecorations.
With it, your Qt applications will:
- take use GNOME Adwaita style theme.
- automatically switch to light or dark, depends on system color style.
- have native header-bar and borders, even when running against Wayland
Install the QGnomePlatform Theme
The QGnomePlatform Theme package is available in system repositories since Ubuntu 23.04. Sadly, it’s built for Qt5 applications only!
For Ubuntu 22.04, I’ve made it into this unofficial PPA for amd64, arm64/hf architectures support.
To install it, press Ctrl+Alt+T on keyboard to open terminal. Then, run the 2 commands below one by one:
- Run command to add the PPA:
sudo add-apt-repository ppa:ubuntuhandbook1/qgnomeplatform
- Then install the theme package:
sudo apt install qgnomeplatform-qt5
NOTE: Ubuntu 23.04 and Ubuntu 23.10 users can directly run the last
apt install command without adding PPA.
After installation, the new theme package should be automatically taken use for your Qt (qt5) apps. Some Qt apps use their own theme options, you have to open their ‘Preferences’ or ‘Settings’ dialog to switch to default or system theme.
If NOT, open ‘Files’ and press Ctrl+H to view hidden files. Then, click editing the ‘.profile‘ file and adding the new line below in the end:
Finally, log out and back in to apply change.
You can remove the Ubuntu PPA after installation, since it will no longer receive updates. To do so, open terminal and run command:
sudo add-apt-repository --remove ppa:ubuntuhandbook1/qgnomeplatform
To remove the theme package, run:
sudo apt remove --autoremove qgnomeplatform-qt5
Also remember to restore the
.profile file in your user home.