如何在不改变其他默认渐变和效果的情况下,改变默认QProgressbar样式的绿色色调(一点明显的“流白块”效应):
默认QProgressbar样式

。
我尝试为QProgressBar::区块:水平使用q线性梯度设置新的背景色组合,但是我没有成功地在任何这样的样式表中保留提到的效果。
发布于 2017-09-19 21:31:38
可能尝试使用这样的计时器更新StyleSheet:
mRunner = 0.1;
QTimer *mTimer = new QTimer(this);
connect(mTimer, SIGNAL(timeout()), this, SLOT(updateProgress()));
mTimer->start(40);方法应该改变每一个新步骤的梯度:
void MainWindow::updateProgress()
{
QString lStyle = QString("QProgressBar::chunk {background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:%1 white, stop:1 #b4b4b4);}").arg(mRunner);
ui->progressBar->setStyleSheet(lStyle);
mRunner += 0.01;
if (mRunner > 1) {
mRunner = 0.1;
}
}https://stackoverflow.com/questions/46308990
复制相似问题