0

I have multiple QLineEdits which are created in a for-loop and stored in a list. I would like to have only one callback function connected to editingFinished for all line edits. Therefore, I need to identify the edited line edit in the callback function. I couldn't find any name or id parameter for QLineEdit. Any suggestions on how to accomplish this?

for attr in measurement_attributes:
    self.label_qLineEdits[attr] = QtWidgets.QLineEdit()
    self.label_qLineEdits[attr].editingFinished.connect(lambda: self.callback_lineEdit_attribute())
clelin
  • 9
  • 1

1 Answers1

0

You could use the sender() method in your slot to get a reference to your QLineEdit, like this:

def callback_lineEdit_attribute(self):
    sending_lineedit = self.sender()
    # (...)
olinox14
  • 6,177
  • 2
  • 22
  • 39