[Interest] Qt-12 with Dark Theme on MacOS Mojave
Till Oliver Knoll
till.oliver.knoll at gmail.com
Fri Dec 21 18:43:14 CET 2018
> Am 21.12.2018 um 08:26 schrieb coroberti . <coroberti at gmail.com>:
>
>> On Thu, Dec 20, 2018 at 9:33 PM Mike Krus <mike.krus at kdab.com> wrote:
>
>> Hi
>>
>> I’ve been tracking QEvent::PaletteChange events, like this:
>>
>> bool MainWindow::event(QEvent *event)
>> {
>> if (event->type() == QEvent::PaletteChange) {
>> QPalette p = palette();
>> m_clearColor = p.color(QPalette::Base);
>> emit clearColorChanged(m_clearColor);
>> }
>>
>> return QMainWindow::event(event);
>> }
>>
>> Event gets sent when switching between themes…
>>
>> Of course, I’m just using the base colour as is, not trying to figure out if it’s light or dark…
>>
>> Hope this helps,
>>
>> Mike
>>
>> > On 20 Dec 2018, at 18:48, coroberti . <coroberti at gmail.com> wrote:
>> >
>> > Hi,
>> > Qt-12 well manages the colors of QWidgets - great job of Qt-developers. Thank you!
>> >
>> > When some background colors are managed by the application,
>> > how to figure out whether it's Light or Dark theme currently in use?
>> >
>> > Another question is how to get notification about the switch between the themes?
>>
>
> Hi Mike,
> Thank you for your reply and the proposed direction.
>
> It looks like what's left for me is to explore how to figure out from
> QPalette mapping to the standard themes.
A practical approach could be:
* If the background colour („background role“) is „darker than some threshold (brightness)“, then the user selected dark mode
* Otherwise light mode
:)
Cheers, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181221/203a3986/attachment.html>
More information about the Interest
mailing list