I have Qt style sheet (qss
) for QLineEdit
, using different styles for readonly and editable. Works fine, but if I toggle a QLineEdit
to readonly (at runtime) the style does not change.
Is there a way to force a stylesheet update of such a line edit?
As requested, the stylesheet:
QLineEdit {
background: transparent;
border: 1px solid green;
border-radius: 5px;
}
QLineEdit[readOnly="true"] {
background: rgba(40,40,40);
border: 1px solid rgba(50,50,50);
}
Here my own findings:
polish
/ unpolish
thing worksQLineEdit
object, it does not work for me if I do it on the parent level (e.g. on a dialog with multiple QLineEdit
s)What works for me is to force an update like this
widget->setStyleSheet(widget->styleSheet());
, by just setting the same stylesheet. I works also on the top level widget, updating multiple child elements.