-
Notifications
You must be signed in to change notification settings - Fork 317
Fix dark mode detection on Linux #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Enable GTK3 platform theme integration on Linux to properly detect system dark/light mode settings. Without this, Qt applications on Linux don't automatically adapt to the system theme, unlike macOS where it works out of the box. The fix sets QT_QPA_PLATFORMTHEME to "gtk3" before QApplication initialization, but only if the user hasn't already set a platform theme. This respects existing user configurations while providing better defaults for desktop environments using GTK (GNOME, Unity, XFCE, MATE). The change is non-breaking as Qt falls back gracefully if the GTK platform theme plugin is unavailable
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. |
Could you please clarify which build this change is intended to affect, statically linked or shared? If the latter, which system was this tested on (OS, desktop environment, Qt version)? |
Seems like this could make things worse for native (Qt) environments? |
this sadly only effects dynamically linked builds. I have tested on ubuntu 24.04 with Qt 6.4.2 |
Bringing this functionality to statically linked (including release) binaries would require introducing new build dependencies. There is a consensus among Core developers that this should only be considered after separating the GUI build into its own Guix script.
On the same system, the master branch @ 34fefb6: ![]() Everything seems to be working correctly. |
Ah, nice and small, thanks. I have a couple of questions. This is in your code:
Does this mean window won't change live when theme changes, on Linux? This is in your post:
Does this mean window will change live when theme changes, on macOS? |
Enable GTK3 platform theme integration on Linux to properly detect
system dark/light mode settings. Without this, Qt applications on
Linux don't automatically adapt to the system theme, unlike macOS
where it works out of the box.
The fix sets QT_QPA_PLATFORMTHEME to "gtk3" before QApplication
initialization, but only if the user hasn't already set a platform
theme. This respects existing user configurations while providing
better defaults for desktop environments using GTK (GNOME, Unity,
XFCE, MATE).
The change is non-breaking as Qt falls back gracefully if the GTK
platform theme plugin is unavailable