Unsolved How to change QLineEdit border color only?
-
My goal is to change the border color of QLineEdit based on the value of a property "valid".
I have added this style:
QLineEdit[valid=false] {border: 1px solid red}
And when I set the property "valid" to false and do the unpolish(), polish() dance I see the red border.
But the border radius is changed as is the padding.
How do I only change the border color and leave the padding and border radius at the default value?
I have considered finding the values of the border radius and padding, but did not find an API call that will return this information.
-
Hi,
Currently you can't. Setting a style sheet will modify which Style is used to render a widget. You'll have to modify you style sheet to also alter the border radius.
-
I was thinking that maybe you could just reimplement paintEvent() and override the pen used to draw the frame.
Have a look at the source of QLineEdit, it shouldn't be impossible
-
And I take it that I cannot get the default radius in any way?