Archives For November 30, 1999

This simple tutorial shows how to install and use Kvantum theme engine to change themes for your Qt5 and Qt6 applications in Ubuntu 20.04 and Ubuntu 23.10.

GNOME Desktop uses GTK toolkit for its applications and KDE/LxQt uses Qt toolkit instead. These apps work on each other desktop environment, but may NOT look native.

To unify the look and feel, Fedora Qt developer team has QGnomePlatform, adwaita-qt, and QAdwaitaDecorations projects to make Qt apps look better in GNOME. So far, only QAdwaitaDecorations is in active development for implementing Adwaita-like window header and border for Qt apps.

For Qt app window color, buttons, and other components, Kvantum is good choice to do the job.

qBittorrent (Qt6) with Kvantum theme in Ubuntu

Continue Reading…

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:

  1. Run command to add the PPA:
    sudo add-apt-repository ppa:ubuntuhandbook1/qgnomeplatform

  2. 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:

export QT_QPA_PLATFORMTHEME='gnome'

Finally, log out and back in to apply change.

Uninstall:

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.

Your apps do NOT have window border and shadow in Ubuntu 24.04? Here are the quick workarounds for the applications based on Qt UI toolkit.

In Linux Desktop, applications are built with different UI toolkit. While, GNOME, Cinnamon, and XFCE use GTK3/4, KDE and LxQt use Qt for their applications.

Ubuntu by default uses GNOME as default desktop environment, but user may also use Qt applications, such as qbittorrent, ksnip screenshot tool, kdenlive video editor, and more.

Since Ubuntu 23.10, the Qt applications are looking weird. They have very thin border without shadow, that look kinda borderless. This is an upstream issue that also happen in Debian 12 bookworm.

Qt apps in Ubuntu 23.10

If you have similar issue, then this tutorial is going to show you how to fix (workaround) it by 2 ways:

  • xcb QPA plugin – for Qt apps run against X11.
  • QGnomePlatform Theme – Qt app inclusion in GNOME, but lack Qt6 support in Ubuntu so far.

NOTE: You can do both ‘Option 1’ and ‘Option 2’ in Ubuntu. They seem not conflicting with each other.

Option 1: Set xcb QPA environment

If most of your Qt apps are running against X11, then this option is a good choice.

1. First, press Ctrl+Alt+T to open up a terminal window. When it opens, run command to install the required libraries:

sudo apt install libxcb-cursor0 libxcb-composite0

Then, you can try to launch a Qt app, qBittorrent from example, from command line with xcb plugin to see if it works:

export QT_QPA_PLATFORM=xcb && qBittorrent

2. If it works, then open “Files“, press Ctrl+H to show hidden files/folders.

Then find out the .profile file, right-click on it and select “Open With Text Editor”.

3. When the file opens, scroll down and add the new line below in the end:

export QT_QPA_PLATFORM=xcb

After saving the file, log out and back in. Then, try launching your Qt applications to see the result.

Tips: without log out and back in, you may press Ctrl+Alt+T to open terminal. Then run command export QT_QPA_PLATFORM=xcb to set the environment for this terminal window. Finally, launch Qt app from this terminal.

Option 2: Use QGnomePlatform Theme

Fedora Linux has QGnomePlatform project to allow Qt applications to fit into the GNOME environment as well as possible, though it’s no longer maintained due to switch to QAdwaitaDecorations.

The theme works great, and even let your Qt apps automatically switch between light and dark mode according to desktop color style.

Ubuntu 23.04 and Ubuntu 23.10 include the package in system repository, sadly for Qt5 apps only!

1. First, press Ctrl+Alt+T on keyboard to open terminal. When terminal opens, run command to install the theme package:

sudo apt install qgnomeplatform-qt5

Ubuntu 24.10 user can also install the qgnomeplatform-qt6 package for Qt6 apps support!

2. Next, also open “Files”, press Ctrl+H to view hidden files. Then, edit the ‘.profile‘ file and add new line in the end:

export QT_QPA_PLATFORMTHEME='gnome'

Finally, log out and back in to apply change.

After doing both ‘Option 1’ and ‘Option 2’, all my Qt applications have native window borders, though the Qt6-based qBittorrent is still not fitting well in GNOME.

Qt apps in Ubuntu 23.10 after this tutorial

Run Qt app against Wayland

After doing ‘Option 1’, your Qt applications will run against X11.

If you do need to run app against Wayland, then either launch the app from terminal. For example, launch kdenlive using wayland:

env QT_QPA_PLATFORM=wayland kdenlive

Tips: some apps may be running silently in the background. You need to close it first before running the similar command above.

Or, edit the app shortcut file (usually under /usr/share/appliations), and set the environment by changing the value of ‘Exec’.

For example, edit the app shortcut for Kdenlive, to make it run against wayland:

sudo gnome-text-editor /usr/share/applications/org.kde.kdenlive.desktop