Can't load external themes when using PySide6
-
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 theplugins/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.
-
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.
-
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.
-
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.
-
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.
-
@SGaist Hmm... interesting. Will look into that.