So I am dynamically creating QLineEdit’s from a range:
for w in range(x):
s = "s"+str(w)
self.s = QtGui.QLineEdit(self)
self.s.setGeometry(QtCore.QRect(15, y, 20, 40))
self.s.setObjectName(_fromUtf8(s))
self.s.show()
y += 40
I am looking to delete those later. I have tried a bunch of things, but it only deletes the last one I add. I can’t find anything explaining why:
for w in range(x):
s="s"+str(w)
self.s.deleteLater()
It works for the last one, but none before that. So it will delete the bottom one of the lists.
Any ideas?
You are setting
sto the name of the QLineEdit, but then you’re deletingself.s, a different variable altogether, which is set in the first loop to the last created QLineEdit. I think you want something like this:Creating
Deleting