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

GTK3 platform theme does not get style name from Gtk

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.2, 5.12.0
    • GUI: Look'n'Feel
    • None
    • Linux/X11

    Description

      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();
      	  
      	    v.setValue(styleNames);
      	}
      	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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes