Unsolved Qt 5.12.1 and Dark mode on macOS Mojave (10.14)
-
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.
-
@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.
-
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 ? -
@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.
-
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. :-) -
-
Awesome @agarny . Thanks very much!
-
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 toQApplication::palette()
. Hence you can't really usesetStyleSheet()
for anything color-related. One particular gotcha isQLabel
, for which I ended up writing my ownColoredLabel
alternative which would receive its current color via callback.