样式
//绿色小方块
style = "QProgressBar {"
"border: 1px solid #bbb;"
"border-radius: 5px;"
"text-align: center;"
"background-color: #eee;"
"}"
"QProgressBar::chunk {"
"background-color: #669966;"//这是方块颜色,#FFC1C1为粉色
"width: 10px;"
"margin: 0.5px;"
"border-radius: 3px;"
"}";
//变态
style = "QProgressBar {"
"border: 1px solid #00ff00;"
"background-color: #000000;"
"color: #00ff00;"
"}"
"QProgressBar::chunk {"
"background-color: #ff0000;"
"border-radius: 3px;"
"width: 10px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 1px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//极简
style = "QProgressBar {"
"border: none;"
"background-color: #ffffff;"
"}"
"QProgressBar::chunk {"
"background-color: #000000;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 5px;"
"margin: 0px;"
"padding: 0px;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"background-color: #f0f0f0;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"background-color: #f0f0f0;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 5px;"
"margin: 0px;"
"padding: 0px;"
"}"
"QProgressBar::chunk:horizontal {"
"border-radius: 0px;"
"}"
"QProgressBar::chunk:vertical {"
"border-radius: 0px;"
"}";
//浏览器
style = "QProgressBar {"
"border: 1px solid #c4c4c4;"
"background-color: #ffffff;"
"color: #000000;"
"text-align: center;"
"}"
"QProgressBar::chunk {"
"background-color: #00b8ff;"
"border-radius: 3px;"
"width: 10px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//绿黑
style = "QProgressBar {"
"border: 1px solid #00ff00;"
"background-color: #000000;"
"color: #00ff00;"
"}"
"QProgressBar::chunk {"
"background-color: #00ff00;"
"border-radius: 5px;"
"width: 50px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//绿黑
style = "QProgressBar {"
"border: 1px solid #8f8f8f;"
"background-color: #000000;"
"color: #00ff00;"
"}"
"QProgressBar::chunk {"
"background-color: #00ff00;"
"border-radius: 5px;"
"width: 50px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//橙黄
style = "QProgressBar {"
"border: 1px solid #FFB900;"
"border-radius: 5px;"
"background-color: #FDDED4;"
"}"
"QProgressBar::chunk {"
"background-color: #FFB900;"
"border-radius: 5px;"
"}"
"QProgressBar::subcontrol:indicator {"
"image: url(:/sunset_rider.png);"
"width: 30px;"
"height: 30px;"
"subcontrol-origin: margin;"
"subcontrol-position: left;"
"border-radius: 5px;"
"}";
//紫色
style = "QProgressBar {"
"border: 1px solid #9c27b0;"
"border-radius: 10px;"
"background-color: #f3e5f5;"
"}"
"QProgressBar::chunk {"
"background-color: #9c27b0;"
"border-radius: 10px;"
"}";
//蓝白色
style = "QProgressBar {"
"border: 1px solid #8f8f8f;"
"border-radius: 5px;"
"background-color: #e6e6e6;"
"}"
"QProgressBar::chunk {"
"background-color: #3d85c6;"
"border-radius: 5px;"
"width: 50px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 2px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 2px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//灰色
style = "QProgressBar {"
"border: 1px solid #c4c4c4;"
"background-color: #f0f0f0;"
"text-align: center;"
"}"
"QProgressBar::chunk {"
"background-color: #666666;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//橙色+紫色
style = "QProgressBar {"
"border: 2px solid #774AFF;"
"background-color: #EDEBFF;"
"color: #774AFF;"
"text-align: center;"
"}"
"QProgressBar::chunk {"
"background-color: #F97B6A;"
"border-radius: 3px;"
"width: 10px;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//蓝色
style = "QProgressBar {"
"border: 1px solid #c4c4c4;"
"background-color: #f0f0f0;"
"text-align: center;"
"}"
"QProgressBar::chunk {"
"background-color: #00b8ff;"
"}"
"QProgressBar::subcontrol:horizontal {"
"height: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::subcontrol:horizontal:disabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:horizontal:enabled {"
"border-color: #8f8f8f;"
"}"
"QProgressBar::subcontrol:vertical {"
"width: 12px;"
"border-width: 1px;"
"border-style: solid;"
"}"
"QProgressBar::chunk:horizontal {"
"border: none;"
"}"
"QProgressBar::chunk:vertical {"
"border: none;"
"}";
//蓝色小方格
style = "QProgressBar {"
"border: 2px solid #c8c8c8;"
"border-radius: 5px;"
"background-color: #f2f2f2;"
"}"
"QProgressBar::chunk {"
"background-color: #0078d7;"
"width: 10px;"
"margin: 0.5px;"
"border-radius: 3px;"
"}";
使用方式
progressbar->setStyleSheet(style);