Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved How to set step (chunk) number in QtProgressBar?

    Mobile and Embedded
    3
    3
    135
    Loading More Posts
    • 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.
    • I
      Inderveer Singh last edited by

      Hi all,
      I am new to Qt . Right now I am trying to create a battery icon for an app. For that I am using QProgressBar and I am trying to set the number of steps for showing the battery capacity.
      Currently the progress bar is showing around 15 steps (chunks) for 100 percent battery.I want to set it to 5 steps such that each step can signify 20 percent battery. I tried to search on internet regarding this query but all I can find is to set value range of battery and size of those steps. Is there a way to set the number of steps in the progress bar?

      JonB raven-worx 2 Replies Last reply Reply Quote 0
      • JonB
        JonB @Inderveer Singh last edited by JonB

        @Inderveer-Singh said in How to set step (chunk) number in QtProgressBar?:

        but all I can find is to set value range of battery and size of those steps. Is there a way to set the number of steps in the progress bar?

        Number of steps == range / size of one step

        ?

        EDIT
        Sorry, my bad, there doesn't seem to be a "size of one step". I don't think you can tell the progress bar how many discrete step markers/individual block width it should have. You can set the minimum & maximum values (range), and the current value within that, and it shows the step blocks/percentage corresponding? Maybe changing the width of the progress bar determines how many physical blocks it contains, I don't know. I stand to be corrected if I am wrong about this....

        1 Reply Last reply Reply Quote 0
        • raven-worx
          raven-worx Moderators @Inderveer Singh last edited by

          @Inderveer-Singh
          by default the chunks are drawn by the platform style (which may be present or not).
          The only way would be to use stylesheets. But you would need to update the stylesheet every time the size of the progressbar changes to get your desired chunk count, whats rather ugly.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply Reply Quote 2
          • First post
            Last post