QProgressBar 3Color

  • Hello Qt community,
    can anyone tell me if it's possible to have several color in one progressbar and how to do that, as i know we can change the color and the background color using setstylesheet. so anyone have any idea how to do that.

    thank's for your help :)

  • Lifetime Qt Champion


    How would you like to customise these 3 collars ?

  • @SGaist said in QProgressBar 3Color:


    my application show different folder the progress bar the 3 color will represent the state of my memory: the first color background will represent the all memory the second color will represent the occupat memory by all folder and the last one will represent the memory of selected folder

  • Hi @benamiar , do you want something like this:-


    Here is the code for that:-

    QProgressBar *progbar = new QProgressBar;
    progbar->setStyleSheet("::chunk {"
                       "background-color: "
                       "qlineargradient(x0: 0, x2: 1, "
                       "stop: 0 green, stop: 0.6 green, "
                       "stop: 0.61 orange, stop: 0.8 orange, "
                       "stop: 0.81 red, stop: 1 red"

  • @Shrinidhi-Upadhyaya
    hello , tnx for your reply , so i think it's kind of what i want as i understood from what you did:

    set value will act on the 3 colors so we will have the 60% of 90% will be green , 20% of 90% will be orange and the rest will be red.

    for the background it's default one . am I wrong ?

    so qlinearGradient is the one who will allow us to have several color, i have another question is their anyway to do that withot the setstylesheet because behind it's using a parser so i don't know if their is a faster way to do that :) ?

    if for exemple i want to stay in 90% and want to change the % of the green without having the stylestyle what should i do ?

Log in to reply