Uniform look for Qt and GTK applications: Difference between revisions

From ArchWiki
m (→‎Troubleshooting: - style: replaced contractions)
 
(95 intermediate revisions by 34 users not shown)
Line 1: Line 1:
[[Category:Widget toolkits]]
[[Category:Widget toolkits]]
[[Category:Eye candy]]
[[Category:Eye candy]]
[[es:Uniform look for Qt and GTK applications]]
[[it:Uniform look for Qt and GTK applications]]
[[ja:Qt と GTK アプリケーションの外観の統合]]
[[ja:Qt と GTK アプリケーションの外観の統合]]
[[ru:Uniform look for Qt and GTK applications]]
[[zh-hans:Uniform look for Qt and GTK applications]]
[[zh-hans:Uniform look for Qt and GTK applications]]
{{Related articles start}}
{{Related articles start}}
Line 24: Line 23:


== Styles for both Qt and GTK ==
== Styles for both Qt and GTK ==
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.


Line 29: Line 29:
{{Note|1=Since version 3.16, GTK 3 [https://bbs.archlinux.org/viewtopic.php?pid=1518404#p1518404 does not support] non-CSS themes, hence previous solutions such as Oxygen-Gtk are [https://bugs.kde.org/show_bug.cgi?id=340288 no longer viable] options.}}
{{Note|1=Since version 3.16, GTK 3 [https://bbs.archlinux.org/viewtopic.php?pid=1518404#p1518404 does not support] non-CSS themes, hence previous solutions such as Oxygen-Gtk are [https://bugs.kde.org/show_bug.cgi?id=340288 no longer viable] options.}}


=== Breeze ===
=== Themes originally Qt based for GTK programs ===


Breeze is the default Qt style of KDE Plasma. It can be installed with the {{Pkg|breeze}} package for Qt5, the {{AUR|breeze-kde4}} package for Qt4, and the {{Pkg|breeze-gtk}} package for GTK 2 and GTK 3.
These are themes originally created for a Qt environment, but was later ported to GTK.
 
==== Breeze ====
 
Breeze is the default Qt style of KDE Plasma. It can be installed with the {{Pkg|breeze}} package and the {{Pkg|breeze-gtk}} package for GTK 2 and GTK 3.


Once installed, you can use one of the many [[GTK#Configuration tools|GTK configuration tools]] to change the GTK theme.  
Once installed, you can use one of the many [[GTK#Configuration tools|GTK configuration tools]] to change the GTK theme.  


If running KDE Plasma, install {{pkg|kde-gtk-config}} and either run it from the command line, or go to ''System Settings > Application Style  > Configure GNOME/GTK Application Style…''. Fonts, icon themes, cursors, and widget styles set in System Settings affect GTK settings automatically; only the GTK theme should be set manually using the previously mentioned module.
If running KDE Plasma, install {{pkg|kde-gtk-config}}, log-out and log-in again, and then go to ''System Settings > Appearance > Application Style  > Configure GNOME/GTK Application Style…''. Fonts, icon themes, cursors, and widget styles set in System Settings affect GTK settings automatically; only the GTK theme should be set manually using the previously mentioned module.


=== Adwaita ===
=== Themes originally GTK based for Qt programs ===


Adwaita is the default GNOME theme. The GTK 3 version is included in the {{Pkg|gtk3}} package, while the GTK 2 version is in {{Pkg|gnome-themes-extra}}. [https://github.com/MartinBriza/adwaita-qt adwaita-qt] is a Qt port of the Adwaita theme. Unlike [[#QGtkStyle]], which mimics the GTK 2 theme, it provides a native Qt style made to look like the GTK 3 Adwaita. It can be [[install|installed]] with the {{AUR|adwaita-qt4}} and {{AUR|adwaita-qt}} packages for the Qt 4 and 5 versions, respectively.
These are themes originally created for a GTK environment, but was later ported to Qt.
 
==== Adwaita ====
 
{{Out of date|Adwaita-qt project is unmaintained and no longer actively developed. [https://github.com/FedoraQt/adwaita-qt#readme]}}
 
Adwaita is the default GNOME theme. The GTK 3 version is included in the {{Pkg|gtk3}} package, while the GTK 2 version is in {{Pkg|gnome-themes-extra}}. [https://github.com/MartinBriza/adwaita-qt adwaita-qt] is a Qt port of the Adwaita theme. Unlike [[#QGtkStyle]], which mimics the GTK 2 theme, it provides a native Qt style made to look like the GTK 3 Adwaita. It can be [[install|installed]] with the {{AUR|adwaita-qt4}}, {{AUR|adwaita-qt5-git}} and {{AUR|adwaita-qt6-git}} packages for the Qt 4, 5 and 6 versions, respectively.


To set the Qt style as default:
To set the Qt style as default:


* For Qt 5, it can be enabled by setting the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_STYLE_OVERRIDE=adwaita}}. Alternatively, use {{Pkg|qt5ct}} package. For more detailed instructions, see [[Qt#Configuration of Qt 5/6 applications under environments other than KDE Plasma]].
* For Qt4, it can be enabled with ''Qt Configuration'' ({{ic|qtconfig-qt4}}), choose ''adwaita'' under ''Appearance > GUI Style''. Alternatively, edit the {{ic|/etc/xdg/Trolltech.conf}} (system-wide) or {{ic|~/.config/Trolltech.conf}} (user-specific) file:
* For Qt4, it can be enabled with ''Qt Configuration'' ({{ic|qtconfig-qt4}}), choose ''adwaita'' under ''Appearance > GUI Style''. Alternatively, edit the {{ic|/etc/xdg/Trolltech.conf}} (system-wide) or {{ic|~/.config/Trolltech.conf}} (user-specific) file:


Line 52: Line 63:
}}
}}


* For Qt 5, it can be enabled by setting the following [[Environment variables#Graphical_environment|environment variable]]: {{ic|1=QT_STYLE_OVERRIDE=adwaita}}. Alternatively, use {{Pkg|qt5ct}} package. For more detailed instructions, see [[Qt#Configuration of Qt5 apps under environments other than KDE Plasma]].
==== GTK themes ported to Kvantum ====
 
Kvantum ({{Pkg|kvantum}}) is an SVG-based style customizer for Qt6 that comes with a variety of built-in styles, including versions of some of popular GTK themes such as Adapta, Arc, Ambiance, Libadwaita and Materia. More themes can be found [https://store.kde.org/browse?cat=123 on the KDE Store]. For Qt5 you additionally need the {{Pkg|kvantum-qt5}} package.
 
Kvantum works as a Qt style instead of a Qt platform theme. To set Kvantum for all Qt applications, set it in {{pkg|qt6ct}} for Qt6 or {{pkg|qt5ct}} for Qt5 respectively, or use the environment variable {{ic|1=QT_STYLE_OVERRIDE=kvantum}}.


=== Kvantum ===
===== Theme configuration =====


Kvantum ({{Pkg|kvantum-qt5}}) is customizable SVG-based theme engine for Qt5 that comes with a variety of built-in styles, including versions of some of popular GTK themes such as Adapta, Arc, Ambiance, Materia.
To [https://github.com/tsujan/Kvantum/blob/master/Kvantum/doc/Theme-Config.pdf configure a theme variant] for Kvantum, such as [https://github.com/GabePoel/KvLibadwaita KvLibadwaita], edit the configuration file:
 
{{hc|/etc/xdg/Kvantum/kvantum.kvconfig (or ~/.config/Kvantum/kvantum.kvconfig)|2=
...
theme=KvLibadwaita
...
}}
 
or use the ''kvantummanager'' GUI.


== Theme engines ==
== Theme engines ==
Line 83: Line 106:
* For Qt 5, it can be enabled by installing {{AUR|qt5-styleplugins}} and setting the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_QPA_PLATFORMTHEME=gtk2}}
* For Qt 5, it can be enabled by installing {{AUR|qt5-styleplugins}} and setting the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_QPA_PLATFORMTHEME=gtk2}}


For full uniformity, make sure that the configured [[GTK#Themes|GTK theme]] supports both GTK 2 and GTK 3. If your preferred theme has inconsistent rendering after configuring Qt to use GTK2, install {{AUR|gtk-theme-switch2}} and choose a theme.
* For Qt 6, it can be enabled by installing {{AUR|qt6gtk2}} and choosing the ''qt6gtk2'' style in {{Pkg|qt6ct}}, or alternatively setting the following environment variable: {{ic|1=QT_QPA_PLATFORMTHEME=gtk2}}
 
For full uniformity, make sure that the configured [[GTK#Themes|GTK theme]] supports both GTK 2 and GTK 3. If your preferred theme has inconsistent rendering after configuring Qt to use GTK2, install {{AUR|gtk-theme-switch2}} and choose a theme. You should also make sure that the preferred theme is installed in {{ic|/usr/share/themes}} as {{ic|$XDG_DATA_HOME/themes}} directory is not being scanned for active GTK 2 theme.


=== QGnomePlatform ===
=== QGnomePlatform ===


This Qt 5 platform theme applies the appearance settings of GNOME for Qt applications. It can be installed with the {{AUR|qgnomeplatform}} package or the {{AUR|qgnomeplatform-git}} package for the development version. It does not provide a Qt style itself, instead it requires a [[#Styles for both Qt and GTK|style that support both Qt and GTK]].
{{Out of date|QGnomePlataform project is unmaintained and no longer actively developed. [https://github.com/FedoraQt/QGnomePlatform#readme]}}
 
This Qt 5 platform theme applies the appearance settings of GNOME for Qt applications. It can be installed with the {{AUR|qgnomeplatform-qt5-git}} and {{AUR|qgnomeplatform-qt6-git}} packages. It does not provide a Qt style itself, instead it requires a [[#Styles for both Qt and GTK|style that support both Qt and GTK]].


This platform theme is enabled automatically in GNOME since version 3.20. For other systems, it can be enabled by setting the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_QPA_PLATFORMTHEME=gnome}}.
This platform theme is enabled automatically in GNOME since version 3.20. For other systems, it can be enabled by setting the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_QPA_PLATFORMTHEME=gnome}}.


== Tips and tricks ==
=== QAdwaitaDecorations ===
=== Using a GTK icon theme in Qt apps ===


{{Style|Duplicates [[environment variables]]}}
QAdwaitaDecorations is Qt decoration plugin implementing Adwaita-like client-side decorations for [[Wayland]]. It can be installed with the {{AUR|qadwaitadecorations-qt5}} and {{AUR|qadwaitadecorations-qt6}} packages. After installing, set {{ic|1=QT_WAYLAND_DECORATION=adwaita}} to environment variable.


If you are running Plasma, install {{Pkg|kde-gtk-config}} and select the icon-theme under ''System Settings > Application Style > GTK''.
== Tips and tricks ==


If you are using [[GNOME]], first check if {{Pkg|dconf-editor}} is installed.
=== Using a GTK icon theme in Qt applications ===


Then, run {{ic|dconf-editor}} and look under ''org > gnome > desktop > interface'' for {{ic|icon-theme}} key and change it to your preferred icon theme.  
If you are running [[Plasma]], run {{Pkg|kde-gtk-config}} and select the icon-theme under ''System Settings > Application Style > GTK''.


If you are not using [[GNOME]], for example if you are running a minimal system with {{Pkg|i3-wm}}, first install {{Pkg|dconf-editor}}.  
If you are using [[GNOME]], run {{Pkg|dconf-editor}} and change the {{ic|icon-theme}} key under ''org > gnome > desktop > interface'' to your preferred icon theme.  


Then, run {{ic|dconf-editor}} and look under ''org > gnome > desktop > interface'' for {{ic|icon-theme}} key and change it to your preferred icon theme.  
If you are not using a [[Desktop environment]], for example if you are running a minimal system with {{Pkg|i3-wm}}, [[install]] {{Pkg|dconf-editor}} and set the icon-theme as explained above.
You might also have to set the value of {{ic|DESKTOP_SESSION}} in your profile. See [[Environment variables#Defining variables]] for the possible ways to obtain the desired result.  


Since, you are not using [[GNOME]], you might have to set the value of {{ic|DESKTOP_SESSION}} in your profile. To do that execute the below code in a terminal and restart your system.
{{Note| If the icon theme was not applied, you might want to check if the name that you entered of your preferred theme, was in the correct format. For example, if you want to apply the currently active icon theme to your QT applications, you can find the correct format of its name with the command:
 
$ echo 'export DESKTOP_SESSION=gnome' >> /etc/profile
 
'''OR'''
 
Set {{ic|1=export DESKTOP_SESSION=gnome}} somewhere in your {{ic|~/.xinitrc}} or, if you are using a [[Display manager]] in [[Xprofile]].
 
{{Note| If the icon theme was not applied, you might want to check if the name that you entered of your preferred theme, was in the correct format. For example, if you want to apply the currently active icon theme to your QT applications, you can find the correct format of it's name with the command:


{{bc|1=$ awk -F= '/icon-theme/ {print $2}' ~/.gtkrc-2.0}}
{{bc|1=$ awk -F= '/icon-theme/ {print $2}' ~/.gtkrc-2.0}}
Line 127: Line 146:
  $ gtk3-nocsd gedit
  $ gtk3-nocsd gedit


=== Improve subpixel rendering of GTK apps under KDE Plasma ===
=== Improve subpixel rendering of GTK applications under KDE Plasma ===


See [[Font configuration#LCD filter]].
See [[Font configuration#LCD filter]].


=== Consistent file dialog ===
=== Consistent file dialog under KDE Plasma ===
 
{{Accuracy|GTK seems to have replaced {{ic|1=GTK_USE_PORTAL=1}} with {{ic|1=GDK_DEBUG=portals}}. https://gitlab.gnome.org/GNOME/gtk/-/blob/636827800525770715bba96671edb2fc0234ccc2/NEWS#L34}}
 
In order to have the same file dialog, one can use [[XDG Desktop Portal]]s.
 
[[Install]] {{Pkg|xdg-desktop-portal}} and {{Pkg|xdg-desktop-portal-kde}} and set {{ic|1=GTK_USE_PORTAL=1}} [[environment variable]].
 
Note that currently not all GTK applications support KDE file dialogs correctly.
 
Applications using electron should use at least electron 14 (see [https://github.com/electron/electron/pull/19159 #19159]) and properly implement this function.
 
[[VSCode]] has a pull request for fixing a problem, see [https://github.com/microsoft/vscode/pull/126113 #126113].
 
[[GIMP]] has not implemented use of the portal yet, see [https://gitlab.gnome.org/GNOME/gimp/-/issues/1830 bug report].
 
{{Note|There are still lots of GTK applications that do not implement portal properly (abandoned applications, or authors are focused on other tasks). To simplify file picking from such applications, you can at least synchronize bookmarks from dolphin to nautilus. Use this command:
 
{{bc|1=$ awk -F\" '/<bookmark href="file/ {print $2}' < $HOME/.local/share/user-places.xbel > $HOME/.config/gtk-3.0/bookmarks}}
 
Alternatively, use {{AUR|bookmarksync-git}} for that purpose. There you can manually edit and sync bookmarks to both sides.
}}
 
==== Application-specific settings ====


In order to have the same file dialog, one can use XDG Portals.
In addition to the environment variable approach, some GTK applications have their own settings for forcing use of XDG Portals:


[[Install]] {{Pkg|xdg-desktop-portal}} and {{Pkg|xdg-desktop-portal-kde}} and set {{ic|1=GTK_USE_PORTAL=1}} as [[environment variable]].
* [[Firefox]] — See [[Firefox#XDG Desktop Portal integration]]


== Troubleshooting ==
== Troubleshooting ==


=== Themes not working in GTK apps ===
=== Themes not working in GTK applications ===


If the style or theme engine you set up is not showing in your GTK applications then it is likely your GTK settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..
If the style or theme engine you set up is not showing in your GTK applications then it is likely your GTK settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..
Line 146: Line 188:
Usually the expected files should be {{ic|~/.gtkrc}} for GTK1 and {{ic|~/.gtkrc2.0}} or {{ic|~/.gtkrc2.0-kde}} for GTK 2.x.
Usually the expected files should be {{ic|~/.gtkrc}} for GTK1 and {{ic|~/.gtkrc2.0}} or {{ic|~/.gtkrc2.0-kde}} for GTK 2.x.


=== GTK apps do not use svg (breeze) icons after system upgrade ===
=== GTK applications do not use svg (breeze) icons after system upgrade ===


Try to run this to fix this issue:
Try to run this to fix this issue:
  # gdk-pixbuf-query-loaders --update-cache
  # gdk-pixbuf-query-loaders --update-cache


=== Flatpak Qt apps do not use Gnome Adwaita dark theme ===
=== GTK applications do not fully use KDE system settings ===


If you switched your theme to Adwaita-dark and Flatpak Qt applications still use the light version, install the required KStyle:
To further integrate [[Plasma]] settings on GTK applications, one may want to [[install]] {{Pkg|gnome-settings-daemon}}, {{Pkg|gsettings-desktop-schemas}} and {{Pkg|gsettings-qt}}. This will offer proper Qt bindings for GTK.


# flatpak install flathub org.kde.KStyle.Adwaita
=== kde-gtk-config "System Settings > Application Style > GTK" menu missing ===


=== Qt apps run on GNOME Wayland have a non-matching window decoration look, even after setting a Qt theme ===
When {{pkg|kde-gtk-config}} breaks and the "Application Style > GTK" menu is missing from System Settings, it is possible to choose [[GTK#Configuration tools|GTK configuration tools]] like {{pkg|lxappearance}} and {{Pkg|nwg-look}} to be able to configure GTK 2 and GTK 3 styles.
{{pkg|lxappearance}} is desktop independent even if it comes from the LXDE project (it does not require other parts of the LXDE desktop). {{Pkg|nwg-look}} is a GTK3 settings editor, designed to work properly in wlroots-based Wayland environment. The look and feel is strongly influenced by LXAppearance, but nwg-look is intended to free the user from a few inconveniences.


In order to have a matching window decoration look, you have to install {{AUR|qgnomeplatform}}, and set the following [[Environment variables#Graphical environment|environment variable]]: {{ic|1=QT_QPA_PLATFORMTHEME='gnome'}}
=== Dolphin theming does not match Nautilus well ===
This fix is guaranteed to work with Adwaita or Adwaita-dark.
Check the section [[Dolphin#Mismatched folder view background colors|Mismatched folder view background colors]] for how to deal with weird coloring.


=== GTK apps do not fully use KDE system settings ===
=== The KDE Plasma XDG Desktop Portal is not being used ===


To further integrate [[Plasma]] settings on GTK apps, one may want to [[install]] {{Pkg|gnome-settings-daemon}}, {{Pkg|gsettings-desktop-schemas}} and {{Pkg|gsettings-qt}}. This will offer proper Qt bindings for GTK.
Follow [[XDG Desktop Portal#Force desktop environment]] with {{ic|XDG_CURRENT_DESKTOP{{=}}KDE}}.


=== kde-gtk-config "System Settings > Application Style > GTK" menu missing===
=== Qt5: kvantum is not available as a style in the Qt settings app ===


When {{pkg|kde-gtk-config}} breaks and the "Application Style > GTK" menu is missing from System Settings, it's possible to choose [[GTK#Configuration tools|GTK configuration tools]] like {{pkg|lxappearance}} to be able to configure GTK 2 and GTK 3 styles.
Be sure to have {{pkg|kvantum-qt5}} installed.
It is desktop independent even if it comes from the LXDE project (it does not require other parts of the LXDE desktop).

Latest revision as of 01:07, 24 April 2024

Qt and GTK based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the "look and feel" differ significantly. This article will help you make your Qt and GTK applications look similar for a more streamlined and integrated desktop experience.

Overview

To get a similar look between the toolkits, you will most likely have to modify the following:

  • Theme: The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.
  • Style: The graphical layout and look of the widget set.
  • Icon Theme: A set of global icons.
  • Color Theme: A set of global colors that are used in conjunction with the style.

You can choose various approaches:

  • Modify GTK and Qt styles separately with the tools listed below for each toolkit and aim for choosing similarly looking themes (style, colors, icons, cursors, fonts).
  • Use a special theme engine, which intermediates the modification of the other graphical toolkit to match your main toolkit.

Styles for both Qt and GTK

There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.

Tip: You may want to apply user defined styles to root applications, see GTK#Theme not applied to root applications and Qt#Theme not applied to root applications.
Note: Since version 3.16, GTK 3 does not support non-CSS themes, hence previous solutions such as Oxygen-Gtk are no longer viable options.

Themes originally Qt based for GTK programs

These are themes originally created for a Qt environment, but was later ported to GTK.

Breeze

Breeze is the default Qt style of KDE Plasma. It can be installed with the breeze package and the breeze-gtk package for GTK 2 and GTK 3.

Once installed, you can use one of the many GTK configuration tools to change the GTK theme.

If running KDE Plasma, install kde-gtk-config, log-out and log-in again, and then go to System Settings > Appearance > Application Style > Configure GNOME/GTK Application Style…. Fonts, icon themes, cursors, and widget styles set in System Settings affect GTK settings automatically; only the GTK theme should be set manually using the previously mentioned module.

Themes originally GTK based for Qt programs

These are themes originally created for a GTK environment, but was later ported to Qt.

Adwaita

This article or section is out of date.

Reason: Adwaita-qt project is unmaintained and no longer actively developed. [1] (Discuss in Talk:Uniform look for Qt and GTK applications)

Adwaita is the default GNOME theme. The GTK 3 version is included in the gtk3 package, while the GTK 2 version is in gnome-themes-extra. adwaita-qt is a Qt port of the Adwaita theme. Unlike #QGtkStyle, which mimics the GTK 2 theme, it provides a native Qt style made to look like the GTK 3 Adwaita. It can be installed with the adwaita-qt4AUR, adwaita-qt5-gitAUR and adwaita-qt6-gitAUR packages for the Qt 4, 5 and 6 versions, respectively.

To set the Qt style as default:

~/.config/Trolltech.conf
...
[Qt]
style=adwaita
...

GTK themes ported to Kvantum

Kvantum (kvantum) is an SVG-based style customizer for Qt6 that comes with a variety of built-in styles, including versions of some of popular GTK themes such as Adapta, Arc, Ambiance, Libadwaita and Materia. More themes can be found on the KDE Store. For Qt5 you additionally need the kvantum-qt5 package.

Kvantum works as a Qt style instead of a Qt platform theme. To set Kvantum for all Qt applications, set it in qt6ct for Qt6 or qt5ct for Qt5 respectively, or use the environment variable QT_STYLE_OVERRIDE=kvantum.

Theme configuration

To configure a theme variant for Kvantum, such as KvLibadwaita, edit the configuration file:

/etc/xdg/Kvantum/kvantum.kvconfig (or ~/.config/Kvantum/kvantum.kvconfig)
...
theme=KvLibadwaita
...

or use the kvantummanager GUI.

Theme engines

A theme engine can be thought of as a thin layer API which translates themes (excluding icons) between one or more toolkits. These engines add some extra code in the process and it is arguable that this kind of a solution is not as elegant and optimal as using native styles.

QGtkStyle

Note: QGtkStyle has been removed from qt5-base 5.7.0 [2] and added to qt5-stylepluginsAUR [3]
Warning: Depending on GTK 2 theme, this style may cause rendering issues such as transparent fonts or inconsistent widgets.

This Qt style uses GTK 2 to render all components to blend in with GNOME and similar GTK based environments. Beginning with Qt 4.5, this style is included in Qt. It requires gtk2 to be installed and configured.

This is the default Qt4 style in Cinnamon, GNOME and Xfce, and the default Qt5 style in Cinnamon, GNOME, MATE, LXDE and Xfce. In other environments:

  • For Qt4, it can be enabled with Qt Configuration (qtconfig-qt4), choose GTK under Appearance > GUI Style. Alternatively, edit the /etc/xdg/Trolltech.conf (system-wide) or ~/.config/Trolltech.conf (user-specific) file:
~/.config/Trolltech.conf
...
[Qt]
style=GTK+
...
  • For Qt 6, it can be enabled by installing qt6gtk2AUR and choosing the qt6gtk2 style in qt6ct, or alternatively setting the following environment variable: QT_QPA_PLATFORMTHEME=gtk2

For full uniformity, make sure that the configured GTK theme supports both GTK 2 and GTK 3. If your preferred theme has inconsistent rendering after configuring Qt to use GTK2, install gtk-theme-switch2AUR and choose a theme. You should also make sure that the preferred theme is installed in /usr/share/themes as $XDG_DATA_HOME/themes directory is not being scanned for active GTK 2 theme.

QGnomePlatform

This article or section is out of date.

Reason: QGnomePlataform project is unmaintained and no longer actively developed. [4] (Discuss in Talk:Uniform look for Qt and GTK applications)

This Qt 5 platform theme applies the appearance settings of GNOME for Qt applications. It can be installed with the qgnomeplatform-qt5-gitAUR and qgnomeplatform-qt6-gitAUR packages. It does not provide a Qt style itself, instead it requires a style that support both Qt and GTK.

This platform theme is enabled automatically in GNOME since version 3.20. For other systems, it can be enabled by setting the following environment variable: QT_QPA_PLATFORMTHEME=gnome.

QAdwaitaDecorations

QAdwaitaDecorations is Qt decoration plugin implementing Adwaita-like client-side decorations for Wayland. It can be installed with the qadwaitadecorations-qt5AUR and qadwaitadecorations-qt6AUR packages. After installing, set QT_WAYLAND_DECORATION=adwaita to environment variable.

Tips and tricks

Using a GTK icon theme in Qt applications

If you are running Plasma, run kde-gtk-config and select the icon-theme under System Settings > Application Style > GTK.

If you are using GNOME, run dconf-editor and change the icon-theme key under org > gnome > desktop > interface to your preferred icon theme.

If you are not using a Desktop environment, for example if you are running a minimal system with i3-wm, install dconf-editor and set the icon-theme as explained above. You might also have to set the value of DESKTOP_SESSION in your profile. See Environment variables#Defining variables for the possible ways to obtain the desired result.

Note: If the icon theme was not applied, you might want to check if the name that you entered of your preferred theme, was in the correct format. For example, if you want to apply the currently active icon theme to your QT applications, you can find the correct format of its name with the command:
$ awk -F= '/icon-theme/ {print $2}' ~/.gtkrc-2.0

Add Title bar and frame to GTK3 applications under KDE Plasma

To have Gnome/GTK applications display with a KDE/Plasma title bar and frame, install gtk3-nocsd-gitAUR and restart your window manager to load the updated library path.

You can also run Gtk application with the wrapper:

$ gtk3-nocsd gedit

Improve subpixel rendering of GTK applications under KDE Plasma

See Font configuration#LCD filter.

Consistent file dialog under KDE Plasma

The factual accuracy of this article or section is disputed.

In order to have the same file dialog, one can use XDG Desktop Portals.

Install xdg-desktop-portal and xdg-desktop-portal-kde and set GTK_USE_PORTAL=1 environment variable.

Note that currently not all GTK applications support KDE file dialogs correctly.

Applications using electron should use at least electron 14 (see #19159) and properly implement this function.

VSCode has a pull request for fixing a problem, see #126113.

GIMP has not implemented use of the portal yet, see bug report.

Note: There are still lots of GTK applications that do not implement portal properly (abandoned applications, or authors are focused on other tasks). To simplify file picking from such applications, you can at least synchronize bookmarks from dolphin to nautilus. Use this command:
$ awk -F\" '/<bookmark href="file/ {print $2}' < $HOME/.local/share/user-places.xbel > $HOME/.config/gtk-3.0/bookmarks

Alternatively, use bookmarksync-gitAUR for that purpose. There you can manually edit and sync bookmarks to both sides.

Application-specific settings

In addition to the environment variable approach, some GTK applications have their own settings for forcing use of XDG Portals:

Troubleshooting

Themes not working in GTK applications

If the style or theme engine you set up is not showing in your GTK applications then it is likely your GTK settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..

$ export | grep gtk

Usually the expected files should be ~/.gtkrc for GTK1 and ~/.gtkrc2.0 or ~/.gtkrc2.0-kde for GTK 2.x.

GTK applications do not use svg (breeze) icons after system upgrade

Try to run this to fix this issue:

# gdk-pixbuf-query-loaders --update-cache

GTK applications do not fully use KDE system settings

To further integrate Plasma settings on GTK applications, one may want to install gnome-settings-daemon, gsettings-desktop-schemas and gsettings-qt. This will offer proper Qt bindings for GTK.

kde-gtk-config "System Settings > Application Style > GTK" menu missing

When kde-gtk-config breaks and the "Application Style > GTK" menu is missing from System Settings, it is possible to choose GTK configuration tools like lxappearance and nwg-look to be able to configure GTK 2 and GTK 3 styles. lxappearance is desktop independent even if it comes from the LXDE project (it does not require other parts of the LXDE desktop). nwg-look is a GTK3 settings editor, designed to work properly in wlroots-based Wayland environment. The look and feel is strongly influenced by LXAppearance, but nwg-look is intended to free the user from a few inconveniences.

Dolphin theming does not match Nautilus well

Check the section Mismatched folder view background colors for how to deal with weird coloring.

The KDE Plasma XDG Desktop Portal is not being used

Follow XDG Desktop Portal#Force desktop environment with XDG_CURRENT_DESKTOP=KDE.

Qt5: kvantum is not available as a style in the Qt settings app

Be sure to have kvantum-qt5 installed.