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
2 Posts 2 Posters 618 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.
  • N Offline
    N Offline
    NinjaCheetah
    wrote on 13 Aug 2024, 01:33 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 Offline
      F Offline
      friedemannkleint
      wrote on 13 Aug 2024, 07:58 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

      1/2

      13 Aug 2024, 01:33

      • Login

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