Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Windows 10 Dark Theme

Windows 10 Dark Theme

Scheduled Pinned Locked Moved Solved General and Desktop
window10
15 Posts 9 Posters 25.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Carl_P
    wrote on 3 Apr 2019, 16:42 last edited by
    #1

    Does Qt support the dark theme for Windows 10? It does on Mac OS and the preview in QtCreator on Windows is displayed using the system colors, but the compiled application displayed using the default or light theme.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 3 Apr 2019, 19:24 last edited by
      #2

      Hi and welcome to the forums.
      There is no official dark theme for compiled Qt apps.
      However, this is pretty nice.
      https://github.com/ColinDuquesnoy/QDarkStyleSheet
      also
      https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle

      However, its based on stylesheets.

      1 Reply Last reply
      3
      • C Offline
        C Offline
        Carl_P
        wrote on 3 Apr 2019, 21:39 last edited by
        #3

        Thank you, this answers my question and helps!

        C 1 Reply Last reply 16 Apr 2019, 16:42
        0
        • C Carl_P
          3 Apr 2019, 21:39

          Thank you, this answers my question and helps!

          C Offline
          C Offline
          Carl_P
          wrote on 16 Apr 2019, 16:42 last edited by Carl_P
          #4

          After trying the links above and a bit of Googling, the solution I ended up using was using QPalettes. This is very similar to the palettes used by Jorken-VikingGod in the link above. The advantage of this over the style sheets is that it it seemed to affect the layout of controls less since it uses the same controls. In case this is useful for anyone else, this code only uses the dark theme if compiling for Windows and the user is using the dark theme. If the user changes the theme while the program is running it does not change back to light, but this is still suitable for my needs. I just added the following to the main() function before showing the main window.

          #ifdef Q_OS_WIN
              QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",QSettings::NativeFormat);
              if(settings.value("AppsUseLightTheme")==0){
                  qApp->setStyle(QStyleFactory::create("Fusion"));
                  QPalette darkPalette;
                  QColor darkColor = QColor(45,45,45);
                  QColor disabledColor = QColor(127,127,127);
                  darkPalette.setColor(QPalette::Window, darkColor);
                  darkPalette.setColor(QPalette::WindowText, Qt::white);
                  darkPalette.setColor(QPalette::Base, QColor(18,18,18));
                  darkPalette.setColor(QPalette::AlternateBase, darkColor);
                  darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
                  darkPalette.setColor(QPalette::ToolTipText, Qt::white);
                  darkPalette.setColor(QPalette::Text, Qt::white);
                  darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
                  darkPalette.setColor(QPalette::Button, darkColor);
                  darkPalette.setColor(QPalette::ButtonText, Qt::white);
                  darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
                  darkPalette.setColor(QPalette::BrightText, Qt::red);
                  darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
          
                  darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
                  darkPalette.setColor(QPalette::HighlightedText, Qt::black);
                  darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
          
                  qApp->setPalette(darkPalette);
          
                  qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
              }
          #endif
          

          I also had to add #include <QStyleFactory> to main.cpp

          V S J 3 Replies Last reply 14 Jan 2020, 15:03
          8
          • C Carl_P
            16 Apr 2019, 16:42

            After trying the links above and a bit of Googling, the solution I ended up using was using QPalettes. This is very similar to the palettes used by Jorken-VikingGod in the link above. The advantage of this over the style sheets is that it it seemed to affect the layout of controls less since it uses the same controls. In case this is useful for anyone else, this code only uses the dark theme if compiling for Windows and the user is using the dark theme. If the user changes the theme while the program is running it does not change back to light, but this is still suitable for my needs. I just added the following to the main() function before showing the main window.

            #ifdef Q_OS_WIN
                QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",QSettings::NativeFormat);
                if(settings.value("AppsUseLightTheme")==0){
                    qApp->setStyle(QStyleFactory::create("Fusion"));
                    QPalette darkPalette;
                    QColor darkColor = QColor(45,45,45);
                    QColor disabledColor = QColor(127,127,127);
                    darkPalette.setColor(QPalette::Window, darkColor);
                    darkPalette.setColor(QPalette::WindowText, Qt::white);
                    darkPalette.setColor(QPalette::Base, QColor(18,18,18));
                    darkPalette.setColor(QPalette::AlternateBase, darkColor);
                    darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
                    darkPalette.setColor(QPalette::ToolTipText, Qt::white);
                    darkPalette.setColor(QPalette::Text, Qt::white);
                    darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
                    darkPalette.setColor(QPalette::Button, darkColor);
                    darkPalette.setColor(QPalette::ButtonText, Qt::white);
                    darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
                    darkPalette.setColor(QPalette::BrightText, Qt::red);
                    darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
            
                    darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
                    darkPalette.setColor(QPalette::HighlightedText, Qt::black);
                    darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
            
                    qApp->setPalette(darkPalette);
            
                    qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
                }
            #endif
            

            I also had to add #include <QStyleFactory> to main.cpp

            V Offline
            V Offline
            Violet Giraffe
            wrote on 14 Jan 2020, 15:03 last edited by Violet Giraffe
            #5

            @Carl_P, this is a great solution and really does work like charm, thanks for sharing! I couldn't find any missing bits that most of the dark stylesheets have.
            The only nitpick I have is that the "Fusion" style doesn't really have the native look and feel. This was enough for me to refuse using this solution, but I love how concise and simple it is. Shame Qt still doesn't support the dark theme natively.

            1 Reply Last reply
            3
            • C Carl_P
              16 Apr 2019, 16:42

              After trying the links above and a bit of Googling, the solution I ended up using was using QPalettes. This is very similar to the palettes used by Jorken-VikingGod in the link above. The advantage of this over the style sheets is that it it seemed to affect the layout of controls less since it uses the same controls. In case this is useful for anyone else, this code only uses the dark theme if compiling for Windows and the user is using the dark theme. If the user changes the theme while the program is running it does not change back to light, but this is still suitable for my needs. I just added the following to the main() function before showing the main window.

              #ifdef Q_OS_WIN
                  QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",QSettings::NativeFormat);
                  if(settings.value("AppsUseLightTheme")==0){
                      qApp->setStyle(QStyleFactory::create("Fusion"));
                      QPalette darkPalette;
                      QColor darkColor = QColor(45,45,45);
                      QColor disabledColor = QColor(127,127,127);
                      darkPalette.setColor(QPalette::Window, darkColor);
                      darkPalette.setColor(QPalette::WindowText, Qt::white);
                      darkPalette.setColor(QPalette::Base, QColor(18,18,18));
                      darkPalette.setColor(QPalette::AlternateBase, darkColor);
                      darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
                      darkPalette.setColor(QPalette::ToolTipText, Qt::white);
                      darkPalette.setColor(QPalette::Text, Qt::white);
                      darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
                      darkPalette.setColor(QPalette::Button, darkColor);
                      darkPalette.setColor(QPalette::ButtonText, Qt::white);
                      darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
                      darkPalette.setColor(QPalette::BrightText, Qt::red);
                      darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
              
                      darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
                      darkPalette.setColor(QPalette::HighlightedText, Qt::black);
                      darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
              
                      qApp->setPalette(darkPalette);
              
                      qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
                  }
              #endif
              

              I also had to add #include <QStyleFactory> to main.cpp

              S Offline
              S Offline
              Seb Tur
              wrote on 21 Aug 2020, 06:10 last edited by
              #6

              @Carl_P

              Do you see any reason why the same build on the same qtlibs would have this dark theme working on some win10 and on some win10 it is still unchanged?

              C 1 Reply Last reply 24 Sept 2020, 17:17
              0
              • l3u_L Offline
                l3u_L Offline
                l3u_
                wrote on 15 Sept 2020, 21:18 last edited by
                #7

                I just stumbled upon this, after successfully having adapted one of my projects to look good in dark mode on Linux/KDE and macOS. Is there anything new about this? Will Qt support Windows's dark mode, as it does on Linux and macOS without having to implement it manually?

                C 1 Reply Last reply 24 Sept 2020, 17:22
                0
                • S Seb Tur
                  21 Aug 2020, 06:10

                  @Carl_P

                  Do you see any reason why the same build on the same qtlibs would have this dark theme working on some win10 and on some win10 it is still unchanged?

                  C Offline
                  C Offline
                  Carl_P
                  wrote on 24 Sept 2020, 17:17 last edited by Carl_P
                  #8

                  @Seb-Tur I don't know exactly. I think the thing I would look at is whether the AppsUseLightTheme setting is located in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize in the version where the dark mode is not working. This can be found in regedit.msc

                  S 1 Reply Last reply 30 Sept 2020, 11:00
                  0
                  • l3u_L l3u_
                    15 Sept 2020, 21:18

                    I just stumbled upon this, after successfully having adapted one of my projects to look good in dark mode on Linux/KDE and macOS. Is there anything new about this? Will Qt support Windows's dark mode, as it does on Linux and macOS without having to implement it manually?

                    C Offline
                    C Offline
                    Carl_P
                    wrote on 24 Sept 2020, 17:22 last edited by
                    #9

                    @l3u_ I think there may be some support for dark mode in Qt 5.15 or at least it may be coming. In the QGuiApplication documentation, there are platform specific command line options, this one looks promising:

                    darkmode=[1|2] controls how Qt responds to the activation of the Dark Mode for applications introduced in Windows 10 1903 (since Qt 5.15).
                    A value of 1 causes Qt to switch the window borders to black when Dark Mode for applications is activated and no High Contrast Theme is in use. This is intended for applications that implement their own theming.

                    A value of 2 will in addition cause the Windows Vista style to be deactivated and switch to the Windows style using a simplified palette in dark mode. This is currently experimental pending the introduction of new style that properly adapts to dark mode.

                    1 Reply Last reply
                    1
                    • C Carl_P
                      24 Sept 2020, 17:17

                      @Seb-Tur I don't know exactly. I think the thing I would look at is whether the AppsUseLightTheme setting is located in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize in the version where the dark mode is not working. This can be found in regedit.msc

                      S Offline
                      S Offline
                      Seb Tur
                      wrote on 30 Sept 2020, 11:00 last edited by
                      #10

                      @Carl_P
                      not present

                      C 1 Reply Last reply 30 Sept 2020, 16:11
                      0
                      • S Seb Tur
                        30 Sept 2020, 11:00

                        @Carl_P
                        not present

                        C Offline
                        C Offline
                        Carl_P
                        wrote on 30 Sept 2020, 16:11 last edited by
                        #11

                        @Seb-Tur Early versions of Windows 10 did not have dark mode, if I recall correctly. I think this came with one of the later updates. If you add this field in regedit, it will work.

                        1 Reply Last reply
                        1
                        • M Offline
                          M Offline
                          mguludag
                          wrote on 22 Jan 2021, 23:35 last edited by
                          #12

                          @Carl_P 's solution combined with Qtimer it'll follows windows 10 mode changes immediately . Here is an example

                          Romain CR E 2 Replies Last reply 16 Mar 2021, 10:50
                          0
                          • M mguludag
                            22 Jan 2021, 23:35

                            @Carl_P 's solution combined with Qtimer it'll follows windows 10 mode changes immediately . Here is an example

                            Romain CR Offline
                            Romain CR Offline
                            Romain C
                            wrote on 16 Mar 2021, 10:50 last edited by Romain C
                            #13
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • C Carl_P
                              16 Apr 2019, 16:42

                              After trying the links above and a bit of Googling, the solution I ended up using was using QPalettes. This is very similar to the palettes used by Jorken-VikingGod in the link above. The advantage of this over the style sheets is that it it seemed to affect the layout of controls less since it uses the same controls. In case this is useful for anyone else, this code only uses the dark theme if compiling for Windows and the user is using the dark theme. If the user changes the theme while the program is running it does not change back to light, but this is still suitable for my needs. I just added the following to the main() function before showing the main window.

                              #ifdef Q_OS_WIN
                                  QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",QSettings::NativeFormat);
                                  if(settings.value("AppsUseLightTheme")==0){
                                      qApp->setStyle(QStyleFactory::create("Fusion"));
                                      QPalette darkPalette;
                                      QColor darkColor = QColor(45,45,45);
                                      QColor disabledColor = QColor(127,127,127);
                                      darkPalette.setColor(QPalette::Window, darkColor);
                                      darkPalette.setColor(QPalette::WindowText, Qt::white);
                                      darkPalette.setColor(QPalette::Base, QColor(18,18,18));
                                      darkPalette.setColor(QPalette::AlternateBase, darkColor);
                                      darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
                                      darkPalette.setColor(QPalette::ToolTipText, Qt::white);
                                      darkPalette.setColor(QPalette::Text, Qt::white);
                                      darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
                                      darkPalette.setColor(QPalette::Button, darkColor);
                                      darkPalette.setColor(QPalette::ButtonText, Qt::white);
                                      darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
                                      darkPalette.setColor(QPalette::BrightText, Qt::red);
                                      darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
                              
                                      darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
                                      darkPalette.setColor(QPalette::HighlightedText, Qt::black);
                                      darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
                              
                                      qApp->setPalette(darkPalette);
                              
                                      qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
                                  }
                              #endif
                              

                              I also had to add #include <QStyleFactory> to main.cpp

                              J Offline
                              J Offline
                              jlagerquist
                              wrote on 28 Apr 2021, 05:30 last edited by
                              #14

                              Using Carl_P's solution works well for my application (Win10) on everything but QWizard and QWizardPage, how do I go about setting the colors on those as well?

                              1 Reply Last reply
                              0
                              • M mguludag
                                22 Jan 2021, 23:35

                                @Carl_P 's solution combined with Qtimer it'll follows windows 10 mode changes immediately . Here is an example

                                E Offline
                                E Offline
                                Ecto Ruseff
                                wrote on 18 Nov 2021, 08:39 last edited by
                                #15
                                This post is deleted!
                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved