Change the background color of a QRadioButton, but its indicator

Simply change the background color of a QRadioButton will also set the background color of the indicator. To avoid this, we need to use style sheets.

QRadioButton {background-color: #C0C0C0;}
QRadioButton::indicator {background: white;border-radius: 7px;border-width: 2px;border-style: solid;width: 10px;height: 10px;}
QRadioButton::indicator:checked {color: black;background: black;border-width: 2px;border-style: solid;border-radius: 7px;border-color: white;}

This is referenced from here.


留言

熱門文章