Available styles change between Creator and deployment
-
I'm currently having a problem with windows Qt styles. I'm using QT 6.8.2, QT Creator 15.0.1, on a Windows 10 machine.
Launched from Creator, with snippet for listing style options
Launched after being deployedMy application was built with the windowsvista style in mind. When launching the application through QT Creator the styles listed by QStyleFactory::keys() are windows11, windowsvista, Windows, Fusion, defaulting to windowsvista. However, when I try to deploy the application using windeployqt.exe the list is reduced to only Windows and Fusion, defaulting to Windows and making the app look like it's from the 95 era: thick emboss buttons, no transparency, etc.
Previously I was using Qt 6.7.0 and did not have this issue, except when executing on a windows 11 machine. How can I get the windowsvista style back into the deployment version? As far as I've found it used to be a standalone .dll file under the styles folder, but that's been replaced by a one-size-fits-all qmodernwindowsstyle.dll.
-
When qmodernwindowsstyle.dll is in there strata with QT_DEBUG_PLUGINS=1 and see why it is not loaded. There are numerous posts about how to debug plug in issues here in the forum.
-
Thanks for your suggestion. I've been able to get QT_DEBUG_PLUGINS=1 while debugging normally via Qt Creator and the plugins are loaded as normal. I was also able to get debug info out of the release build using DebugView from Microsoft and found that it was no longer searching the APPDIR/styles folder created by windeployqt.exe for qmodernsindowsstyle.dll. I attempted to force it to load using QLibrary but that didn't do anything. Finally, I moved qmodernwindowsstyle.dll to a new folder APPDIR/plugins/styles, which seems to be the new default. That made it load qmodernwindowsstyle.dll properly and I was able to set it back to windowsvista.
In a previous build I have of the project compiled with Qt 6.7.0, the APPDIR/styles folder is searched properly and qmodernwindowsstyle.dll is loaded without any modification to the file structureas set by windeployqt. Wondering if that's been documented somewhere or if it's a change that's been missed. In any case, I'm adding a post build step to do this for me and it's solved for now.
-
-
This post is deleted!
-
@StevePosh, thank you! I've been going mad trying to figure out why it won't load.
Did you create a bug report for this?
-
The style plugin has to be under <appdir>\styles - no code or anything else needed. This was true for every qt5 and qt6 version.
D:\development\Qt-bin\6.8.2\msvc2022_64\bin\tmp λ assistant.exe -style windows11 ... qt.core.plugin.factoryloader: checking directory path "D:/development/Qt-bin/6.8.2/msvc2022_64/bin/tmp/styles" ... qt.core.plugin.factoryloader: looking at "qmodernwindowsstyle.dll" qt.core.plugin.loader: Found metadata in lib D:/development/Qt-bin/6.8.2/msvc2022_64/bin/tmp/styles/qmodernwindowsstyle.dll, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "windowsvista", "windows11" ] }, "archlevel": 0, "className": "QModernWindowsStylePlugin", "debug": false, "version": 395264 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("windowsvista", "windows11") qt.core.library: "D:/development/Qt-bin/6.8.2/msvc2022_64/bin/tmp/styles/qmodernwindowsstyle.dll" loaded library
-
Then it is also true that
windeployqt
used to place it correctly, and no longer does. Resulting in broken deployments and literal hours of debugging.