Qt World Summit: Submit your Presentation

QProgressBar inverted logic: 0 -> full, 1 -> empty

  • Hi

    Is it somehow possible to have the QProgressBar have an inverted display logic, say:
    Range 0-100.
    Value 0: ProgressBar shows "full"
    Value 100: ProgressBar is "empty"


  • Lifetime Qt Champion


    You can call

    progressBar->setValue(progressBar->maximum() - newValue);

    Hope it helps

  • Of course, this starts from top. However, the value displayed will then change as well.

    Range: 0-100
    NewValue = 10
    How I would like it to be:
    Value shown: 10, Progressbar 9/10 "full"

    How it is with maximum-NewValue = 90
    Value shown: 90, Progressbar 9/10 "full"

    Since QProgressBar does not have a property to do this I'll then will go the way of not displaying the value and use a separate label instead to be able to seperate the value shown in text and the value shown on the bar as a workaround.

    Thanks anyway!

  • Lifetime Qt Champion

    You can subclass QProgressBar and reimplement the text function to return what you want.

Log in to reply