Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set a native Qt theme in Qt 5.15.9 on GNOME?

How to set a native Qt theme in Qt 5.15.9 on GNOME?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rutledgea20
    wrote on 2 Jul 2024, 17:19 last edited by
    #1

    This is related to a previous post I made here, but I've managed to narrow it down much more.

    I have a Qt 5.15.9 application built for Red Hat Enterprise Linux 9 (using GNOME), which is having issues with the QGtk3Theme plugin (from qt5/plugins/platformthemes/libqgtk3.so). Just based on the name, it seems like this class should only be involved in Qt if a gtk style is being used, but I can't seem to bypass it.

    I found this thread which highlights some issues with libqgtk in newer versions of Qt5:
    https://forum.qt.io/topic/75398/qt-5-8-0-qapplication-invalid-style-override-passed-ignoring-it/7
    And it suggests this solution:

    qputenv("QT_STYLE_OVERRIDE", "");
    

    I tried this with the empty string, and also with "Windows" and "Fusion", which are the only two styles that print when I use:

    qDebug() << QStyleFactory::keys();
    

    None of that changed the segfault I get in QGtk3Theme::QGtk3Theme().

    I've also found this page which seems to describe something similar, QGtkStyle:
    https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications#QGtkStyle
    What it describes makes sense, some Qt themes (are those different from styles?) rely on gtk in the backend. It seems like QGtk3Theme is just the gtk3 version of QGtkStyle. It says you can enable this theme by setting the QT_QPA_PLATFORMTHEME environment variable to "gtk2", but I just want to disable it. I've tried setting that variable to "gnome", "qt5ct", or just "" in the source code before setting style override to Fusion or Windows, but still get the same segmentation fault.

    I think I generally understand what QGtk3Theme is, and I also expect it to break. This app was originally made in RHEL7 with qt4, and that version also broke when trying to use a gtk-based style like GTK+. It instead used the adwaita style, which looks like gtk but is still native Qt.
    What I don't understand is why I can't seem to enable a native Qt style that doesn't depend on gtk in RHEL9. Is there some other way that gtk themes can be enforced that I'm missing?

    I even tried running the RHEL7/qt4 version of the app on RHEL9, and the same sort of thing happens. Even with the style set to adwaita, a native Qt style, the program segfaults in gtk libraries just like it does when adwaita is disabled on RHEL7.

    Any help is appreciated, thanks.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rutledgea20
      wrote on 2 Jul 2024, 22:45 last edited by
      #5

      I figured out a solution that did not require any new version of QT or messing with the libraries.
      Setting the environment variable XDG_CURRENT_DESKTOP=kde did the trick. I have yet to test with the Qt4 version, but since it works for Qt5 and that was my original question I am marking this solved.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 2 Jul 2024, 18:29 last edited by
        #2

        Hi,

        From past memory, I remember there has been some fixes for GTK3 at some point. You may have to build a more recent version of Qt 5 or maybe consider using Qt 6.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        R 1 Reply Last reply 2 Jul 2024, 18:38
        0
        • S SGaist
          2 Jul 2024, 18:29

          Hi,

          From past memory, I remember there has been some fixes for GTK3 at some point. You may have to build a more recent version of Qt 5 or maybe consider using Qt 6.

          R Offline
          R Offline
          rutledgea20
          wrote on 2 Jul 2024, 18:38 last edited by
          #3

          @SGaist Do you think it's possible for me to just not use the GTK3 stuff at all? I have no attachment to any style, and I don't think the original software was even designed to use it at all. It seems like it's just being forcibly enabled somehow in RHEL9.

          Installing new software is kind of a big pain on this system, so I'd like to try everything I can before that.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 2 Jul 2024, 19:37 last edited by
            #4

            One thing you can do is move the GTK platform theme library somewhere else.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rutledgea20
              wrote on 2 Jul 2024, 22:45 last edited by
              #5

              I figured out a solution that did not require any new version of QT or messing with the libraries.
              Setting the environment variable XDG_CURRENT_DESKTOP=kde did the trick. I have yet to test with the Qt4 version, but since it works for Qt5 and that was my original question I am marking this solved.

              1 Reply Last reply
              0
              • R rutledgea20 has marked this topic as solved on 2 Jul 2024, 22:45

              4/5

              2 Jul 2024, 19:37

              • Login

              • Login or register to search.
              4 out of 5
              • First post
                4/5
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved