Enable Support for Dark Theme for Titlebar in Windows

When using the windows dark theme it's annoying to have white titlebars on some apps. I noticed that this app which and I would like to use on Windows but the lack of dark theme on the titlebar makes it not fit in well. I did some research on this and found that the best way to set it seems to be using the darkmode toggle on the platform. That can be set as a parameter or environment variable. This seems to be the easiest way to set it. I tested this locally on a Win11 VM and it looks to work the same as setting -platform windows:darkmode=1 or setting QT_QPA_PLATFORM=windows:darkmode=1. Note this does need to be set before the QApplication is originally created and so I think it has to be done per app to work. If I missed some other way to set this that would be better I would be interested to know more.

QT Docs: https://doc.qt.io/qt-5/qguiapplication.html#platform-specific-arguments
remotes/origin/work/svuorela/remove-write-only-variable-1
Nicholas Omann 3 years ago committed by Albert Astals Cid
parent 048349d330
commit f0e3581bab
  1. 9
      shell/main.cpp

@ -27,6 +27,15 @@
int main(int argc, char **argv)
{
/**
* enable dark mode for title bar on Windows
*/
#if defined(Q_OS_WIN)
if (!qEnvironmentVariableIsSet("QT_QPA_PLATFORM")) {
qputenv("QT_QPA_PLATFORM", "windows:darkmode=1");
}
#endif
/**
* enable high dpi support
*/

Loading…
Cancel
Save