0

I added some QProgressBar inside a list and I need to use that list to set the values of these ProgressBar

        self.DataBar = list()
        for Nb in range(0, 4):
            self.DataBar.append(BarPourcentage(self))
            self.DataBar[Nb].setValue(12)
            self.DataBar[Nb].show()
            print(self.DataBar[Nb].value())
        self.DataBar[2].setValue(50) #This line isn't working, it works only when Nb=0 

        class BarPourcentage(QtWidgets.QProgressBar): #My Class
            def __init__(self, parent = None):
            super(BarPourcentage, self).__init__()
            self.setParent(parent)
            self.setGeometry(200,80,130,20)

With the print, it prints the 4 values of there 4 progressbar. I can see these 4 progressbar on my gui but i can't change their value individually by trying DataBar[Value].setValue(50) when value isn't equal to 0. Error : list index out of range.

Cheen
  • 86
  • 3
  • 12
  • I think i found the error which was the line 7 was inside the loop... – Cheen May 02 '19 at 07:29
  • 1
    are you sure you have the same indentations in full code ? If `self.DataBar[2]` is inside `for` loop then it can give this error because it is executed when list has only one element. – furas May 02 '19 at 07:29
  • Yes exactly, That was the problem but i'm having another problem now, i will tell you soon. – Cheen May 02 '19 at 07:32
  • if you have new problem then create new question on new page. – furas May 02 '19 at 07:38

0 Answers0