Petr
Petr

Reputation: 14485

Qt: is there any way to adapt toolbar icons to system theme?

One of users of my program recently reported an issue with the UI when using dark system theme. Most of issues were caused by me as I hardcoded some colors instead of using system colors. I could fix this easily, but one thing remains. Some of the toolbar icons are almost black and hard to see on dark theme, here is screenshot made by user:

Example

You can see that first 3 icons in toolbar are hard to see in this theme.

Is there any mechanism inside of Qt that I could use to recognize dark theme and adjust the icons, or even switch to some "dark theme" version? Or is there some function in Qt that would make the icons visible on dark theme? It can already alter colors of icons in case that button is disabled, maybe there is some function that can make them lighter?

Upvotes: 1

Views: 669

Answers (1)

HeyYO
HeyYO

Reputation: 2073

How about using windows background color to determine if its a dark color?

window.palette().window().color().lightnessF()

Upvotes: 3

Related Questions