Jan Grulich

Qt theming in Fedora Workstation

We have been working on and using custom Qt theming in Fedora Workstation for many years now. By custom Qt theming, I’m talking about the QGnomePlatform and Adwaita-qt projects. If you haven’t heard of them, you can read my recent blog post explaining what they are. While these projects are in some ways better than what Qt upstream has to offer, there were also drawbacks/issues and that’s why I decided to make a final decision and discontinue both projects. The issues are explained in the aforementioned blog post, but one of the main drawbacks is that we are in this development alone and not working directly in the upstream makes it less attractive for other contributors. It’s also not used by default anywhere other than Fedora, so it’s not properly tested by other developers working on Qt applications using different distributions. These reasons led me to submit a Fedora 39 feature to remove our custom Qt theming in Fedora Workstation in favor of Qt’s defaults. The only problem is that if we just go with Qt’s default, we would go backwards a bit. This is because upstream Qt does not provide any decent client-side window decorations (problem #1), and the QGtkTheme in Qt5 (QGnomePlatform equivalent) is a bit behind its Qt6 version with many improvements and integration goodies (problem #2) recently made by Axel Spoerl of the Qt Group, whom I met during this year’s KDE Akademy.

Solution to problem #1

QGnomePlatform used to be our solution to this problem, as QGnomePlatform implemented it’s own version of the QWaylandAbstractDecoration plugin. This was a GTK 3-like decoration plugin that used Adwaita-qt for button rendering and QGnomePlatform bits (e.g. GSettings configuration) to get the titlebar layout. Since we are going to remove QGnomePlatform, we needed an alternative. So I started working on the QAdwaitaDecorations project. This is supposed to be a an intermediate step as I would like to have a proper GNOME/Gtk decorations directly in Qt upstream, but since I was in a hurry to get everything done in time for Fedora 39, we have this for now. QAdwaitaDecorations plugin is based on the decorations we have in QGnomePlatform, but there is no dependency on GTK or Glib (e.g. GSettings) or on Adwaita-qt. We use xdg-desktop-portal to get the titlebar layout and do our own drawing instead. This decoration plugin should also have now a GTK 4-like style so the buttons and colors of the decorations are different.

Below is a screenshot of Wireshark (Qt6) using QAdwaitaDecorations plugin + QGtkTheme + Fusion:

Solution to problem #2

Since Qt5 is no longer actively developed, the only possible solution is to backport all QGtkTheme improvements from Qt6, so I did that + modified some of those changes to avoid breaking binary compatibility. This results in about ~15 related backports to Qt5 so far, and it seems to work pretty well. I also made sure that Fedora 38 and older will still use QGnomePlatform by default, so we don’t change the behavior for existing users. Also, a small change to our QtWayland package was needed to make it use the new decoration plugin by default.

Future plans

As mentioned, I would really like to have everything directly in Qt upstream (talking about QAdwaitaDecorations). That way we get other contributions and thus fixes/improvements for free and a lot more users. Another thing is that QGnomePlatform supports things that are not yet supported/implemented in QGtkTheme, like support for xdg-desktop-portal instead of just relying on GSettings. Not to mention that GTK 4 has been around for a while, and both QGnomePlatform and QGtkTheme are still GTK 3 based. I will definitely try to make some of these things happen for Fedora 40, but knowing myself, it’s better not to make any promises, as things usually don’t go according to plan.

14 thoughts on “Qt theming in Fedora Workstation

  1. I wish for a final solution for the ugly Adwaita theme embedded in that cursed LibAdwaita library, every app built on top of it cannot be used on any non GNOME desktop due to its inconsistent look with the rest of the desktop. Those selfish GNOME devs destroyed one of the beautiful libraries in Linux world.

    1. No one forces app developers to use LibAdwaita, and no one forces you to use LibAdwaita apps.

      Also, you can theme LibAdwaita apps using Gradience.

  2. The correct solution for #1 is for Mutter so support SSDs, you can’t retroactively add requirements to toolkits to do drawing.

    1. The actual correct solution would be for Qt to have a good CSD implementation instead of what it currently have. Requiring a feature of an out-of-tree project because your implementation is lacking wont do you any favor.

    1. I’ve been looking into that and even talked to David Edmunson about it, but the way libdecor works it’s not easy to integrate it with QtWayland.

  3. I don’t understand how to use QAdwaitaDecorations. I can’t even tell if it’s being used or not.

    I updated from Fedora 38 to 39. qadwaitadecorations-qt6 is installed.

    As far as I can tell, setting `export QT_WAYLAND_DECORATION=adwaita` makes no difference one way or another, whether `QT_QPA_PLATFORMTHEME` is set or not.

    By default (without QT_QPA_PLATFORMTHEME) Fusion is used with a horrible color palette where secondary highlighting doesn’t work because several of the palette colors are the same. If QT_QPA_PLATFORMTHEME is set to qt6ct, then some slightly less horrible colors are used.

    QT applications no longer switch into dark mode (except the for the GNOME managed titlebar) wihen “gsettings set org.gnome.desktop.interface color-scheme prefer-dark” are used.

  4. Wireshark looks nothing like your screenshot. How do I make it use the “QAdwaitaDecorations plugin + QGtkTheme + Fusion” configuration you mention?

      1. Hmm. Well, I’m confused because as I said, I am on Fedora 39 and Wireshark looks nothing like your screenshot. How do you make it into dark mode? “gsettings set org.gnome.desktop.interface color-scheme prefer-dark” does not (unless QT_QPA_PLATFORMTHEME=gnome is set, which radically changes the appearance, but my understanding is that is deprecated now.) I have qadwaitadecorations-qt6 installed and QT_WAYLAND_DECORATION=adwaita set (but unexporting that environment variable makes no difference.)

        Perhaps there is something set somewhere from this machine being upgraded, but it doesn’t seem like decorations happen at all.

      2. QT_LOGGING_RULES=”qt.qpa.qadwait*.debug=true” wireshark

        Gives log messages like:
        ” ** (wireshark:152267) 17:14:09.548989 [GUI ECHO] — Using Qt6 version
        ** (wireshark:152267) 17:14:09.551915 [GUI ECHO] — Changing color scheme to light

        In another terminal:
        $ gsettings set org.gnome.desktop.interface color-scheme prefer-dark


        ** (wireshark:152267) 17:14:49.043606 [GUI ECHO] — Changing color scheme to dark
        ** (wireshark:152267) 17:14:49.078975 [GUI ECHO] — Changing color scheme to dark

        But no Qt6 widgets actually change to dark mode. The titlebar does, and the GNOME apps do. But no Qt apps.

  5. I upgraded to Fedora 39 recently, and spent a number of hours trying to get my window decorations back to normal. “export QT_QPA_PLATFORM=xcb” worked for me.

    1. That’s a step backwards, because that way your app is not running natively on Wayland. Maybe next time report what’s wrong with QAdwaitaDecorations so we can make it better?

  6. What I find is that the Qt “gtk3” platform theme will read whether to use dark or light mode from “gtk-application-prefer-dark-theme = true” in ~/.config/gtk-3.0/settings.ini or similar, but completely ignores “gsettings set org.gnome.desktop.interface color-scheme prefer-dark” (and similar commands that do that in the GUI.)

    It will also respect the “GTK_THEME” environment variable, like setting it to “Adiwata:dark”. But the ability to change on the fly definitely does not work with the “gtk3” platform theme. Apparently it’s looking for gtk settings changing “gtk-application-prefer-dark-theme”, but I’m not sure how the org.gnome.desktop.interface color-scheme setting gets translated into that.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll To Top