Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QProgressBar 3Color
Forum Updated to NodeBB v4.3 + New Features

QProgressBar 3Color

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 706 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benamiar
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How would you like to customise these 3 collars ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        benamiar
        wrote on last edited by benamiar
        #3

        @SGaist said in QProgressBar 3Color:

        customise

        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

        1 Reply Last reply
        0
        • Shrinidhi UpadhyayaS Offline
          Shrinidhi UpadhyayaS Offline
          Shrinidhi Upadhyaya
          wrote on last edited by
          #4

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

          0_1560427795577_32f16319-5e08-4b99-838d-c6b0e9b5a269-image.png

          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"
                             ")}");
          progbar->setValue(90);
          

          Shrinidhi Upadhyaya.
          Upvote the answer(s) that helped you to solve the issue.

          B 1 Reply Last reply
          3
          • Shrinidhi UpadhyayaS Shrinidhi Upadhyaya

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

            0_1560427795577_32f16319-5e08-4b99-838d-c6b0e9b5a269-image.png

            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"
                               ")}");
            progbar->setValue(90);
            
            B Offline
            B Offline
            benamiar
            wrote on last edited by benamiar
            #5

            @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 ?

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved