QT 自定义进度条(显示网络质量)

QT 自定义进度条(显示网络质量)_第1张图片

在网上找了很多样式,没有类似的,自己实现了一下,纯qss实现,方便使用。

很多时候需要检测网络质量,此时需要类似进度调的样式来显示,qss如下:

最上面的:

QProgressBar{
	border:1px solid #0000ff;
	height:30;
	background:transparent;
	text-align:center;
	color:rgb(255,0,0);
 	border-radius:10px;
}


QProgressBar::chunk{
	border-radius:5px;    
	border:1px solid #63d389;
	background-color:#63d389;
	width:8px;
	height:20px;
	margin:0.5px;
	margin-top:2px;
}

下面红色的:

QProgressBar{
	border:none;
	height:30;
	background:transparent;
	text-align:center;
	color:transparent;
 	border-radius:10px;
}


QProgressBar::chunk{
	border-radius:0px;    
	background-color:#ff0000;
	width:8px;
	height:20px;
	margin:0.5px;
	margin-top:2px;
}

最后是绿色的:

QProgressBar{
	border:none;
	height:30;
	background:transparent;
	text-align:center;
	color:transparent;
 	border-radius:10px;
}


QProgressBar::chunk{
	border-radius:0px;    
	border:1px solid #63d389;
	background-color:#63d389;
	width:8px;
	height:20px;
	margin:0.5px;
	margin-top:2px;
}

 

其实都差不多,主要就是chunk的设置,希望对各位初学者受用。

你可能感兴趣的:(qt,qprogressbar,网格状)