qt - How do I gray-out a label without disabling it? -


i have few labels want grayed-out, depending on variable. of labels have effects (such changing factors) when clicked. i'd program regardless of theme user using, can't hardcode colors. how can this?

i can think of several solutions, of them have annoying drawbacks:

  • change text color: sounds easiest solution, it's bit harder since want support theming/palettes. if system theme changed while program running, since i'd have update palette again.

  • call setdisabled() , override event: feels wrong, , risks overriding platform behavior.

  • make custom text widget: possible, of course, require either lot of code duplication , wasted time, or rather half-assed , limited implementation.

  • wrap paintevent pair of setdisabled() calls: no. no. also, don't know if work concurrency.

you can set style sheet of label, since it's widget. works me , when themes changed because of os switching or whatever, keeps same.

label.setstylesheet("color: gray") 

the style sheet have css syntax. can make wonderful things it, have on reference properties , examples distinct widgets.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -