Running Ubuntu, Fedora, Debian etc Linux with GNOME, but your Qt-based applications do not have window borders? This quick tutorial is going to show you how to fix the issue.
Many GNOME based Linux Distributions have switch to Wayland as default session. However, Qt applications seem not rendering good. In Debian 12 with GNOME, all my Qt apps (e.g., Ksnip and KeepassXC) just look weird without window borders (See top feature image).
And, when trying to launch it from terminal, it output something looks like:
QSocketNotifier: Can only be used with threads started with QThread
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
If have similar issue on any Linux with GNOME Wayland, then this tutorial could help!
Method 1: Use QGnomePlatform
According to this bug report, user can choose to use QGnomePlatform to theme Qt applications to fit into GNOME environment.
1. Install QGnomePlatform
First, search for and open a terminal window from the overview screen.
When terminal opens, select run one of the below commands according to your system:
- For Debian and Ubuntu based systems, run command:
sudo apt install qgnomeplatform-qt5
- For Fedora based systems, use command:
sudo dnf install qgnomeplatform-qt5 qgnomeplatform-qt6
- And for Arch/Manjaro, use command:
sudo pacman -S qgnomeplatform-qt5 qgnomeplatform-qt6
2. Verify if it looks OK
Before applying the new QPlatformTheme, you may verify if it will work by launching a Qt app from terminal.
To do so:
- First, set Qt platform theme environment for this terminal only:
export QT_QPA_PLATFORMTHEME='gnome'
- Then, start a Qt app from terminal to see the result. In the case, I launched qBittorrent via command:
qbittorrent
3. Apply the theme for current user
If your Qt app looks OK after running commands in last step, then you can make it permanent by setting the environment into config file.
To do so:
- First, open ‘Files’ (aka Nautilus file manager), press Ctrl+H on keyboard to open hidden file folders. Then, click edit either
.profile
,.bash_login
, or.bash_profile
depends your system (only one exists).
When the file opens in text editor, add the new line to the end and save it.
export QT_QPA_PLATFORMTHEME='gnome'
When done, log out and back in to apply changes.
Method 2: Use Kvantum
Kvantum is SVG-based theme engine for Qt5/6. It has some built themes to make your QT apps fit well into GNOME environment.
1. Install kvantum
Like QGnomePlatform, kvantum is also available in most Linux system repositories.
To install it, first search for and launch a terminal window from the overview screen.
When terminal opens, select run one of the commands below to install kvantum:
- For Debian and Ubuntu systems, run command:
sudo apt install qt5-style-kvantum
- For Fedora based systems, use command:
sudo dnf install kvantum
- And for Arch, Manjaro, etc, run command:
sudo pacman -S kvantum
2. Set a Theme for Qt apps
Then, search for and launch “Kvantum Manager” from the overview screen.
When the tool opens, navigate to “Change/Delete Theme“, then choose a theme from the drop-down box (e.g., KvGnome). Finally, click “Use this theme” button to apply it.
3. Verify if your Qt Apps look OK
Also, before making it permanent, you can start a Qt app from terminal to preview the theme change.
To do so:
- Open terminal and run command to set the environment from this terminal only:
export QT_STYLE_OVERRIDE=kvantum
- Then, launch a Qt app (qbittorrent in the case) from terminal to see the UI changes:
qbittorrent
4. Make Kvantum Theme Permanent
To apply the Kvantum theme, you have to set the environment by writing the rule into user profile.
To do so:
- First, open ‘Files’ (aka Nautilus file manager), press Ctrl+H on keyboard to open hidden file folders. Then, click edit either
.profile
,.bash_login
, or.bash_profile
depends your system (only one exists). - When the file opens in text editor, add the new line to the end and save it.
export QT_STYLE_OVERRIDE=kvantum
When done, log out and back in to apply changes.
Method 3: Use XCB qt plugin
For choice, there’s also the classic XCB plugin for running Qt applications against X11 (also works in Wayland).
You may also open terminal and run the commands below one by one to try it out:
- Set the environment:
export QT_QPA_PLATFORM=xcb
- Launch a Qt application (qbittorrent in the case) from terminal, then see if the UI looks OK:
qbittorrent
If you want, make it permanent by editing either ‘.profile
‘, ‘.bash_profile
‘, or ‘.bash_login
‘ in user home directory (press Ctrl+H to view), and finally add the new line below in the end:
export QT_QPA_PLATFORM=xcb
Finally, save the file and log out and back in to apply.