代码实现更改控件样式表的颜色和形状等
//QLabel控件变成圆形LED指示灯样式表
const QString QLabel_LED_Circle_SheetStyle_Red = "min-width: 20px; min-height: 20px;max-width:20px; max-height: 20px;border-radius: 10px; background:red";//红色
const QString QLabel_LED_Circle_SheetStyle_Green = "min-width: 20px; min-height: 20px;max-width:20px; max-height: 20px;border-radius: 10px; ;background:green";//绿色
const QString QLabel_LED_Circle_SheetStyle_Gray = "min-width: 20px; min-height: 20px;max-width:20px; max-height: 20px;border-radius: 10px; border:1px solid black;background:grey";//灰色
const QString QLabel_LED_Circle_SheetStyle_Yellow = "min-width: 20px; min-height: 20px;max-width:20px; max-height: 20px;border-radius: 10px; border:1px solid black;background:yellow";//黄色
ui->led->setStyleSheet(QLabel_LED_Circle_SheetStyle_Red);// 红色圆形警示灯
第二种方法:
声明:
void QT_QLabel_LED_Set(QLabel *label,QString rgb_color,bool