How to change QProgressBar color



  • Hi,
    I would like to change color of my progress bar from default green to red. I have this code, but the view is "flat", I would like to achieve something like "3d effect" as on picture below:
    0_1540375998673_pb.png

    Code for red PB:
    QPalette pal = ui->pbExtractionWidget->palette();
    pal.setColor(QPalette::Normal, QColor(Qt::red));
    QString danger = "QProgressBar::chunk {background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 #FF0350,stop: 0.4999 #FF0020,stop: 0.5 #FF0019,stop: 1 #FF0000 );border-bottom-right-radius: 5px;border-bottom-left-radius: 5px;border: .px solid black;}";
    ui->pbExtractionWidget->setStyleSheet(danger);
    This is how it looks:
    0_1540376231641_pbr.png


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It's the style sheet that triggers that as the widget is rendered through a different style and doesn't follow the system style anymore.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.