Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Can't load external themes when using PySide6
Forum Updated to NodeBB v4.3 + New Features

Can't load external themes when using PySide6

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 4 Posters 1.0k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    NinjaCheetah
    wrote on last edited by NinjaCheetah
    #1

    I have an app build with PySide6 that attempts to load the system Qt library path so that it can then load a theme like Breeze (or possibly another theme the user has installed, though currently it just tries to load Breeze, and then Kvantum if Breeze doesn't exist, before just resigning itself to using Fusion). The problem that I'm having is that no theme other than Fusion and the "Windows" theme will actually load.

    Before the main window is shown, my app runs the following code:

    if os.path.isdir("/usr/lib/qt6/plugins"):
        app.addLibraryPath("/usr/lib/qt6/plugins")
        print(QStyleFactory.keys())
        if "Breeze" in QStyleFactory.keys():
            app.setStyle("Breeze")
        elif "kvantum" in QStyleFactory.keys():
            app.setStyle("kvantum")
    

    The issue is that no matter what theme I specify, it will never actually load that theme, unless I try to load "Windows", in which case it will use the 9x theme. When it prints the keys in QStyleFactory, it gives me ['Breeze', 'Oxygen', 'kvantum-dark', 'kvantum', 'Windows', 'Fusion'], which is telling me that the system library path is loading, since my system themes are all there.

    I've also tried just using the --style override, but it seems that the additional library path is added after the arguments are parsed, so I can't use that to load a system theme.

    My last thing to try was adding the .so for a given theme directly into the plugins/styles directory for PySide6, which, interestingly, always causes the 9x theme to load instead of Fusion. This means that I can't even load an external theme added to PySide6's copy of Qt, so this isn't just an issue with external library paths.

    I don't hate Fusion or anything, but it would just be nice to actually be able to load additional themes at all, since this has prevented me from doing it either automatically or through any sort of menu in the app.

    1 Reply Last reply
    0
    • F Online
      F Online
      friedemannkleint
      wrote on last edited by
      #2

      Most likely, the Qt build used for PySide is not compatible with the build on the system. Please run with the environment variable QT_DEBUG_PLUGINS set and check the output.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        johnzhou721
        wrote last edited by
        #3

        Hi @friedemannkleint -- can you elaborate? Like, would it help if I installed the same PySide6 version as my system Qt version? I'm exactly experiencing this right now.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          johnzhou721
          wrote last edited by
          #4

          FWIW I have tried downgrading PySide6 to match system Qt version but it still does not work. Someone help! Because of some other Fedora bugs in packaing a system pyside6 (I install it through system reboot and it will blackscreen there's some deps issues) I have no way to package any PySide6 application that uses Breeze at this moment! Thanks! Unlike the name implies, this is not being a Breeze.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote last edited by
            #5

            Hi,

            If the package provided by Fedora is somehow broken then you need to build PySide6 yourself with the Qt version provided by the distribution.

            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
            • J Offline
              J Offline
              johnzhou721
              wrote last edited by
              #6

              @SGaist Hmm... interesting. Will look into that.

              1 Reply Last reply
              0

              • Login

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