diff options
| author | Volker Hilsheimer <[email protected]> | 2025-12-03 15:57:48 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <[email protected]> | 2025-12-05 18:36:08 +0000 |
| commit | 672ad85d9475a5c02bfe877b16ac25d969cf9c41 (patch) | |
| tree | 6cf025ca76453964fbef5fccf4faec9e917e85ee /src | |
| parent | 7704edb6d9632726b2d7381f4848cb7c1e852503 (diff) | |
Windows style: override the application palette when in dark mode
The native Windows (XP) styling code cannot render controls in the dark
color scheme. Our code detects that the application is running in dark
mode, and then explicitly creates a light palette that gets set on the
QQuickTheme singleton.
However, the palette that the style is actually using isn't always based
on the QQuickTheme palette, so we get inconsistent colors: the window
background is dark, a button font is light, while the button itself is
also light. This makes the UI unusable.
QGuiApp has no knowledge of Qt Quick's styling infrastructure, or of
QQuickTheme, so it cannot ask the style to "polish" the palette like we
do in widgets.
As a quick fix, override the global QGuiApplication palette with the
light palette.
[ChangeLog][Controls] The Windows native style will use a light palette
as the application global palette on Windows systems running in dark
mode. The style cannot render dark controls, and mixing a dark
application palette with some UI elements rendered in light mode using
the Control style results in inconsistent and unusable user interfaces.
For Dark mode UIs, use a style that supports dark mode, like the
FluentWinUI3 or Fusion styles.
Pick-to: 6.10 6.8
Change-Id: I5e279b88ba018baa03936624e07f48e8986eb1c6
Reviewed-by: Oliver Eftevaag <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quicknativestyle/qstyle/windows/qquickwindowsstyle.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/quicknativestyle/qstyle/windows/qquickwindowsstyle.cpp b/src/quicknativestyle/qstyle/windows/qquickwindowsstyle.cpp index 62b8b79cc9..5be34237f5 100644 --- a/src/quicknativestyle/qstyle/windows/qquickwindowsstyle.cpp +++ b/src/quicknativestyle/qstyle/windows/qquickwindowsstyle.cpp @@ -2295,6 +2295,7 @@ void QWindowsStyle::refreshPalette() if (auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration())) nativeWindowsApp->populateLightSystemPalette(pal); QQuickTheme::instance()->setPalette(QQuickTheme::System, pal); + QGuiApplication::setPalette(pal); } void QWindowsStyle::polish() |
