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(), overrideevent: 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
painteventpair ofsetdisabled()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
Post a Comment