まあ、何を私は持っているが、それは、スタイルシートを使用するよりもはるかに高速で、QProgressBarの派生クラスを使用している正常に動作するよう、カスタム調整幅と高さ:
void ColorBar::paintEvent(QPaintEvent *pe)
{
QRect region = pe->rect();
QPainter painter(this);
QColor borderColor;
borderColor.setNamedColor("#a0a0a0");
QColor lightColor = QColor(255, 255, 255);
QColor darkColor = QColor(225, 225, 225);
int barHeight = static_cast<int>(height() * 1./4. + 0.5);
QRect drawRect(0, static_cast<int>(height()/2. - barHeight/2. + 0.5), width() * .9 * value()/maximum(), barHeight);
QLinearGradient g(drawRect.topLeft(), drawRect.bottomLeft());
g.setColorAt(0., lightColor);
g.setColorAt(1., darkColor);
painter.setPen(QPen(borderColor));
painter.setBrush(QBrush(g));
painter.drawRect(drawRect);
}
このバーがあるのアニメーションを簡単で速い:
QPropertyAnimation* x = new QPropertyAnimation(percentageBar, "value");
x->setStartValue(percentageBar->value());
x->setEndValue(newValue);
x->setDuration(500);
x->start();
フィードバックやより良いソリューションのためにまだ開いている!
少し改善されていますが、色をキャッシュすると 'QLinearGradient'は' paintEvent'実装の速度を少し上げます。 –