Stylesheet inheritance with pseudo-states
-
Hi,
I have a stylesheet issue.
Using this notation:#my_widget #my_label { color: black; } #my_widget:focus #my_label { color: white; }my_label is always using a white text color, even if my_widget is not focused.
The focus itself works, tested with background color of my_widget.Is there any reason why this descendant usage doesn't work properly?
Thanks,
Megamouse -
Hi,
I have a stylesheet issue.
Using this notation:#my_widget #my_label { color: black; } #my_widget:focus #my_label { color: white; }my_label is always using a white text color, even if my_widget is not focused.
The focus itself works, tested with background color of my_widget.Is there any reason why this descendant usage doesn't work properly?
Thanks,
MegamouseIt turns out the solution is to use the existing QProperty declarations in the QWidget header:
#my_widget #my_label { color: black; } // This does not work // #my_widget:focus #my_label { // color: white; // } // This works #my_widget[focus="true"] #my_label { color: white; }Sadly, to make this work, you still need to check the focus events of your parent widget and do:
my_label->style()->unpolish(my_label); my_label->style()->polish(my_label);Also, the hover state doesn't seem to be represented as QProperty, so I'll have to add that property manually and query the QHoverEvents