0
Good afternoon, you guys! I need each line of qLinedit to be numbered in ascending order from 1 to 24, I created a qLabel for this, but I don’t know how to make it change the numbering according to each line, I was only able to print a lot of [i] as shown in the image[here]1. What can I do?
self.ql_coords = {}
self.num = {}
#nós
lo_nodes = qg.QGridLayout()
#no = qg.Qlabel('Node')
x = qg.QLabel('x:')
y = qg.QLabel('y:')
z = qg.QLabel('z:')
for i in range(0,24):
self.num[str(i+1)+str(0)] = qg.QLabel('[i]') #cria a qlabel
lo_nodes.addWidget(self.num[str(i+1)+str(0)], i+1, 0) #adiciona a qlabel ao layout
for j in range(1,4):
self.ql_coords[str(i)+str(j)] = qg.QLineEdit() #cria as qlineedits
lo_nodes.addWidget(self.ql_coords[str(i)+str(j)], i+1, j) #adiciona as qlineedits ao layout
lo_nodes.addWidget(x, 0, 1)
lo_nodes.addWidget(y, 0 ,2)
lo_nodes.addWidget(z, 0, 3)
Changing text of a Qlabel at runtime is completely different from creating Qlabel at runtime, it would be good to clarify. If you want to create, just pass the string in the creation (which seems to be your case, but you are passing a fixed string instead of using the variable). If you want to change (ie change an existing Qlabel), you have to call the . setText method
– Bacco