17 November 2022
Lorenzo CastellinoI just updated from PySide 6.3.2 to 6.4.0.1 and it seems that dark/light mode for the application is automatically applied from system settings. Is there a way to override it and just stick to the light theme?
You can invert the app palette with the following code before creating any widgets:
palette: QtGui.QPalette = app.palette()
cr: QtGui.QPalette.ColorRole
for cr in QtGui.QPalette.ColorRole.__members__.values():
if cr == QtGui.QPalette.ColorRole.NColorRoles:
continue
color: QtGui.QColor = palette.color(cr)
color = QtGui.QColor.fromHslF(color.hueF(), color.saturationF(), 1. - color.lightnessF())
palette.setColor(cr, color)
app.setPalette(palette)
Lorenzo CastellinoI just updated from PySide 6.3.2 to 6.4.0.1 and it seems that dark/light mode for the application is automatically applied from system settings. Is there a way to override it and just stick to the light theme?
591d8b4cc0 Windows: Turn on dark mode support by default
Dark mode, both for the window frames and for the palette, is now
supported by default. It can be turned off (partially or entirely) by
setting the QPA parameter "darkmode=0" (no dark mode support) or
"darkmode=1" (darkmode support only for the window frames).
FreyaFrom https://code.qt.io/cgit/qt/qtreleasenotes.git/about/qt/6.4.0/release-note.md
Was looking for this but DuckDuckGo was giving me an hard time... I was sure it was somewhere out there
Lorenzo CastellinoWas looking for this but DuckDuckGo was giving me an hard time... I was sure it was somewhere out there
https://wiki.qt.io/Qt_6.4_Release has all those linked at the very bottom
Freya591d8b4cc0 Windows: Turn on dark mode support by default
Dark mode, both for the window frames and for the palette, is now
supported by default. It can be turned off (partially or entirely) by
setting the QPA parameter "darkmode=0" (no dark mode support) or
"darkmode=1" (darkmode support only for th
Looking into it it seems that this holds for windows but I'm trying to get a way to deal with the light/dark theme override in a cross-platform manner
Freya591d8b4cc0 Windows: Turn on dark mode support by default
Dark mode, both for the window frames and for the palette, is now
supported by default. It can be turned off (partially or entirely) by
setting the QPA parameter "darkmode=0" (no dark mode support) or
"darkmode=1" (darkmode support only for th
When they say the WPA parameter, I believe that is for the platform plugin.
So, I think if you pass: -platform windows:dark mode=0 as one of the parameters that QApplication processes, that should do it.
ThomasI’m currently using this within main, before passing the argv to the QApplication’s __init__
if not os.getenv("QT_QPA_PLUGIN") and "-platform" not in argv and platform.system() == "Windows":
argv.append("-platform")
argv.append("windows:darkmode=2")
You can use darkmode=0 to disable it inste
Ah someone mentioned it k
Keith KyzivatAh someone mentioned it k
As far as I know, the -platform parameter takes precedence over the environment variable. Thus the check to only explicitly set the option if nothing is passed via the environment or explicitly via argv. This still allows the user to override the behaviour, if they wish