今天查阅网上很多设置QRadioButton文本颜色显示,大部分都是使用图片来达到文字改色的效果。
使用代码也能达到同样的效果;
QString sRadioButtonStyle=QString("QRadioButton{background-color:rgb(%1);font-width:bold;}"
/*选中框样式*/ "QRadioButton::indicator{width: 20px;height: 20px;color:#888888}"
"QRadioButton{font-size: 16px;color: #888888;}"
/*点击状态*/ "QRadioButton::checked{color:#FF0000;}"
/*未点击状态*/ "QRadioButton::unchecked{color:#888888;}").arg(sBgColor1);
setStyleSheet(sRadioButtonStyle);
QRadioButton其他样式:qss之QRadioButton_qradiobutton qss_王廷云的博客的博客-CSDN博客