Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72506

GTK3 platform theme does not get style name from Gtk



    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.9.2, 5.12.0
    • Fix Version/s: None
    • Component/s: GUI: Look'n'Feel
    • Labels:
    • Platform/s:


      I thought that when starting Qt 5 applications in a Gtk based desktop environment, they were supposed to emulate the desktop look and feel by loading a Qt style with the same name as the global Gtk theme, if available. This does not appear to be the case when I run under MATE, however - instead, the program will look for a "static" list of styles; something like { "fusion", "windows" }.

      Based on source code inspection, it looks like the problem is that platform plugin 'gtk3' simply doesn't check the gtk-theme-name setting, or handle the theme hint QPlatformTheme::StyleNames in any other way - a request for the hint data will just revert to a fall-back from a general base class. This suggests that you will get the same problem with desktops like GNOME, XFCE, LCDE and Cinnamon. On GNOME 3, you can get around the issue by using a 3rd party plugin from https://github.com/FedoraQt/QGnomePlatform, but it will get the theme directly from GNOME specific "dconf" keys, and is thus not suitable for the other desktops mentioned, with the possible exception of Cinnamon.

      The problem may be solved by adding the following case to switch statement in QGtk3Theme::themeHint(), file src/plugins/platformthemes/gtk3/qgtk3theme.cpp

          case QPlatformTheme::StyleNames: {
      	QVariant v = QGnomeTheme::themeHint(hint);
      	QString gtkTheme=gtkSetting("gtk-theme-name");
      	if (!gtkTheme.isEmpty()) {
      	    QStringList styleNames;
      	    styleNames << gtkTheme << v.toStringList();
      	return v;

      Note: I encountered this issue on system with a Qt 5.9.2, but tried replacing the plugin with a version I built from Qt 5.12 sources, and that did not resolve the problem.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            qt.team.quick.subscriptions Qt Quick and Widgets Team
            toralf.lund@pgs.com Toralf Lund
            1 Vote for this issue
            4 Start watching this issue



                Gerrit Reviews

                There are no open Gerrit changes