Get the Qt5 app to use the native Gtk+ style in Ubuntu or Debian

Some Qt5 applications do not use Gtk+ styles by default in Gnome (for example in Ubuntu 18.04), which makes them look out of place. Including VirtualBox, VLC, qBittorrent, Simple Screen Recoder, ownCloud desktop client and other applications, this article describes how to solve this problem and how to make Qt5 applications in Debian or Ubuntu (and based on the use of Gnome desktop Ubuntu (such as Pop!_OS) ).
[[Edit] For fresh Ubuntu 20.04 and 19.10 installations (which will not happen if you upgrade from an older Ubuntu), use QT_QPA_PLATFORMTHEME=gtk2 It greatly reduces the startup speed of Qt5 applications, so please do not use it. Please use Kvantum instead, it does not have this problem, and it also allows you to choose the theme you want to use for your Qt5 application.
Use the adjusted VLC and VirtualBox in this article on Ubuntu 18.04:

  • prior to:

vlc qt5 ugly Ubuntu 18.04

  • Rear:

VirtualBox Qt5 gtk + style Ubuntu 18.04vlc qt5 gtk + style Ubuntu 18.04Related: Use Kvantum to use custom themes for Qt applications on Linux To solve this problem and make Qt5 applications use Gtk+ style, all you have to do is follow these simple steps: 1. Install qt5-style-plugins, Which contains Cleanlooks, Motif, Plastique and Gtk + 2 Qt5 style packages.

sudo apt install qt5-style-plugins

2. Set the Qt5 application to use Gtk + 2 style by adding export QT_QPA_PLATFORMTHEME=gtk2 Give you ~/.profile. To do this, execute the following command:

echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile

3. Log out after installing this package.
After logging in again, Qt5 applications (such as qBittorrent, VLC or Virtualbox) should use the Gtk+ style on the Gnome desktop of Debian or Ubuntu (and Ubuntu-based Pop!_OS).
It is important to note that this solves the problem of apps installed via apt/deb. This adjustment does not apply to applications installed with Snap, Flatpak or AppImage software packages. At least this is the case on my Ubuntu 18.04 desktop.