> Am 21.12.2018 um 08:26 schrieb coroberti . <corobe...@gmail.com>:
>
>> On Thu, Dec 20, 2018 at 9:33 PM Mike Krus <mike.k...@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 . <corobe...@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
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest