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. Qt 5.12.1 and Dark mode on macOS Mojave (10.14)
Forum Updated to NodeBB v4.3 + New Features

Qt 5.12.1 and Dark mode on macOS Mojave (10.14)

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 9.8k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    Hi,

    I am trying to get my application (built using Qt 5.12.1) to look right in Dark mode on macOS, but... I am really struggling. There are so many things that just don't work with Qt in that regards (https://bugreports.qt.io/browse/QTBUG-73788 and https://bugreports.qt.io/browse/QTBUG-73852 are just a couple of bugs that I have recently reported, but I could have reported many more... but then I would be working full time reporting bugs...!).

    Yet, according to https://bugreports.qt.io/browse/QTBUG-68891, it looks like Qt 5.12 supports Dark mode on macOS...?!

    For example, something that I had been assuming is that QEvent::PaletteChange would get triggered every time we were to switch from Light to Dark mode (and vice versa), but it’s not the case. In fact, when switching modes, most of my application's colours don't change.

    In other words, I think I should be able to get my application to look kind of ok in Dark mode. However, to switch to Light mode while my application is running will result in the UI being completely messed up. (The same applies when starting in Light mode and then switching to Dark mode.)

    So... has anyone managed to get their application to work fine in Dark mode? If so, what am I missing?...

    Cheers, Alan.

    A 1 Reply Last reply
    0
    • A agarny

      Hi,

      I am trying to get my application (built using Qt 5.12.1) to look right in Dark mode on macOS, but... I am really struggling. There are so many things that just don't work with Qt in that regards (https://bugreports.qt.io/browse/QTBUG-73788 and https://bugreports.qt.io/browse/QTBUG-73852 are just a couple of bugs that I have recently reported, but I could have reported many more... but then I would be working full time reporting bugs...!).

      Yet, according to https://bugreports.qt.io/browse/QTBUG-68891, it looks like Qt 5.12 supports Dark mode on macOS...?!

      For example, something that I had been assuming is that QEvent::PaletteChange would get triggered every time we were to switch from Light to Dark mode (and vice versa), but it’s not the case. In fact, when switching modes, most of my application's colours don't change.

      In other words, I think I should be able to get my application to look kind of ok in Dark mode. However, to switch to Light mode while my application is running will result in the UI being completely messed up. (The same applies when starting in Light mode and then switching to Dark mode.)

      So... has anyone managed to get their application to work fine in Dark mode? If so, what am I missing?...

      Cheers, Alan.

      A Offline
      A Offline
      agarny
      wrote on last edited by
      #2

      @agarny said in Qt 5.12.1 and Dark mode on macOS Mojave (10.14):

      For example, something that I had been assuming is that QEvent::PaletteChange would get triggered every time we were to switch from Light to Dark mode (and vice versa), but it’s not the case. In fact, when switching modes, most of my application's colours don't change.

      This one is actually really weird and I am not able to reproduce it consistently. In other words, sometimes QEvent::PaletteChange gets triggered and sometimes it doesn't.

      Anyway, for now, I have given up on adding support for Dark Mode in my application. I am just enforcing the use of Light Mode and that is that.

      J.HilkJ 1 Reply Last reply
      0
      • A agarny

        @agarny said in Qt 5.12.1 and Dark mode on macOS Mojave (10.14):

        For example, something that I had been assuming is that QEvent::PaletteChange would get triggered every time we were to switch from Light to Dark mode (and vice versa), but it’s not the case. In fact, when switching modes, most of my application's colours don't change.

        This one is actually really weird and I am not able to reproduce it consistently. In other words, sometimes QEvent::PaletteChange gets triggered and sometimes it doesn't.

        Anyway, for now, I have given up on adding support for Dark Mode in my application. I am just enforcing the use of Light Mode and that is that.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @agarny
        you could make it a toggle able option in your app settings and later add automatic detection. Once/if the issues have been fixed ?


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        A 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          hi @agarny
          you could make it a toggle able option in your app settings and later add automatic detection. Once/if the issues have been fixed ?

          A Offline
          A Offline
          agarny
          wrote on last edited by
          #4

          @J.Hilk said in Qt 5.12.1 and Dark mode on macOS Mojave (10.14):

          you could make it a toggle able option in your app settings and later add automatic detection. Once/if the issues have been fixed ?

          Sorry, I am not sure I understand what you are suggesting. What would that option toggle? The light/dark mode? And, what automatic detection?

          Anyway, I have now enforced the use of Light Mode and updated the "Known limitations" of my documentation. Not something that I am happy with, but I have spent (read: wasted) far too much time on this and now need to move on.

          1 Reply Last reply
          1
          • S Offline
            S Offline
            steveq
            wrote on last edited by
            #5

            Hi @agarny
            Would you mind posting a code snippet of how you enforced light mode under QT please?
            Dark mode is giving me all sorts of grief, and I can't find a way of detecting which mode MacOS is running in.
            I too think I will resort to forcing light mode until a better option presents itself.
            Thanks!
            Steve Q. :-)

            A 1 Reply Last reply
            0
            • S steveq

              Hi @agarny
              Would you mind posting a code snippet of how you enforced light mode under QT please?
              Dark mode is giving me all sorts of grief, and I can't find a way of detecting which mode MacOS is running in.
              I too think I will resort to forcing light mode until a better option presents itself.
              Thanks!
              Steve Q. :-)

              A Offline
              A Offline
              agarny
              wrote on last edited by agarny
              #6

              @steveq, all you need is to add the following two lines to Info.plist file:

              <key>NSRequiresAquaSystemAppearance</key>
              <string>true</string>
              

              See here for the context.

              1 Reply Last reply
              3
              • S Offline
                S Offline
                steveq
                wrote on last edited by
                #7

                Awesome @agarny . Thanks very much!

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  khrykin
                  wrote on last edited by khrykin
                  #8

                  You can't reliably detect macOS appearance change in Qt, but nevertheless full dark mode support is achievable, though may require a bit of extra work. Key point is to do all your styling, i.e. backgrounds, borders, etc. in paintEvent() and relate all relevant colors to QApplication::palette(). Hence you can't really use setStyleSheet() for anything color-related. One particular gotcha is QLabel, for which I ended up writing my own ColoredLabel alternative which would receive its current color via callback.

                  1 Reply Last reply
                  1

                  • Login

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