Search code examples
pythoneditorpyqt5statusbarprogress

PyQt5 Can i remove Progress from Statusbar when Checkbox is uncheckd?


So i'am new to PyQt5 and i'am trying to remove progress from the status bar when the Checkbox is unchecked. Now, when i hit the Checkbox and check it, the status bar set the progress 1 step forward.But when i unchecked the status bar, the progress is still set on the steps from forward. here is my code to this.

def deactivate_header(self, state):
    if state == QtCore.Qt.Checked:
        self.ui.headerText.setDisabled(True)
        self.ui.fBar.setValue(25)
    else:
        self.ui.headerText.setDisabled(False)
        self.ui.fBar.setValue(-25)

Can someone help me?


Solution

  • Using the progress bar's setValue method sets the absolute value, it doesn't adjust the value from where it is. To move the progress bar's value back by 25 when the checkbox is unchecked try:

    self.ui.fBar.setValue(self.ui.fBar.value() - 25)