Solved Stylesheets: pseudo states in descendants selectors
-
Is it possible use pseudo-states inside descendants selectors
For example:
I need change child label color if parent button have focused stateQPushButton:focus QLabel { ... color: #FFFFFF; }
But this selector dont works.
Also i found this topic https://stackoverflow.com/questions/21911820/qt-how-to-set-color-of-child-labels-while-hover-parent-frame but it looks little bit outdated.
Can someone confirm is it possible use pseudo states inside descendants selectors?
-
Hi
I don't think so.
I also tried for :focus but it seems to read it asQPushButton QLabel
{}
and thus ignore the pseudo-state
Even for a container like QFrame where QLabel is really inside it still ignores
the:focus part so its doubtfull it can work. ( or at least i didn't find the right formula)However, to actually have QLabel inside button must mean you have a custom control
and hence you could handle it internally via
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e); -
@mrjj my current solution works on overriden focusInEvent/focusOutEvent. Sollution works but i also want mede this only with QSS.
Thanks for response. -
@goldstar2154
Hi
ok, it seems QSS do not support it / ignores it and applies the keys regardless of parent has focus.