QProgressBar *b = new QProgressBar();
QString progressStyle = QString("::chunk {"
"background-color: "
"qlineargradient(x0: 0, x2: 1, "
"stop: 0 green, stop: 0.6 green, "
"stop: 0.6 orange, stop: 0.8 orange, "
"stop: 0.8 transparent, stop: 1 transparent"
")}");
b->setStyleSheet(progressStyle);
b->setValue(80);
b->show();
I'm trying to use solid colors, each color separated from the other, but my code results in gradient colors.
Here's how it looks:
How can I avoid this gradient effect, and achieve the solid colors I need?
Try adding 0.0001
, to avoid color ranges from overlapping, which causes the gradient effect.
Solid colors:
"stop: 0 green, stop: 0.6 green, "
"stop: 0.60001 orange, stop: 0.8 orange, "
"stop: 0.80001 red, stop: 1 red"
Gradient:
"stop: 0 green, stop: 0.6 green, "
"stop: 0.6 orange, stop: 0.8 orange, "
"stop: 0.8 red, stop: 1 red"