Qt通过样式表设置颜色时控制台警告:
QCssParser::parseColorValue: Specified color without alpha value but alpha given: ‘rgb 0, 0, 0,0’
警告代码为
ProgressBar[i]->setStyleSheet("QProgressBar{color:rgb(0,0,255);border-radius: 5px;font:5px;"
"background: rgb(0, 0, 0,0);}"
"QProgressBar::chunk {border-radius: 5px;"
"background: rgb(255, 0, 0);}" );
原因:第二行的background: rgb(0, 0, 0,0)
设置了透明度,但是rgb()不支持设置透明度;
解决:把rgb()换成rgba()
ProgressBar[i]->setStyleSheet("QProgressBar{color:rgb(0,0,255);border-radius: 5px;font:5px;"
"background: rgba(0, 0, 0,0);}"
"QProgressBar::chunk {border-radius: 5px;"
"background: rgb(255, 0, 0);}" );