> 文章列表 > Qt设备状态显示

Qt设备状态显示

Qt设备状态显示

1、QLable法

 void setLED (QLabel* label,int color,int size){label->setText("");QString min_width =QString("min-width: %1px;").arg(size);//QString min_height =QString("min-height: %1px;").arg(size);//QString max_width =QString("max-width: %1px;").arg(size);//QString max_height =QString("max-height: %1px;").arg(size);QString border_radius =QString("border-radius: %1px;").arg(size/2);//QString border =QString("border:1px solid black;");//QString background ="background-color:";switch(color){case 0:background+="rgb(190,190,190)";break;case 1:background+="rgb(255,0,0)";break;case 2:background+="rgb(0,255,0)";break;case 3:background+="rgb(255,255,0)";break;default:break;}const QString SheetStyle = min_width + min_height + max_width + max_height + border_radius + border + background;label->setStyleSheet(SheetStyle); }