I'm learning (by doing) python, and writing a program that will work on multiple text-files at the same time. The file-names are given in QLineEdit widgets of GUI. I wanted to add a function that checks on enter if these files exist. Being lazy I don't want to create multiple instances of check-if-exist, but to pass the QLineEdit as an argument.
Being naive I tried code below, but I get error 'QLineEdit not defined'
class My_App(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
...
self.ui.lineEdit_1.returnPressed.connect(self.CheckFileExist(self.ui.lineEdit_1))
self.ui.lineEdit_2.returnPressed.connect(self.CheckFileExist(self.ui.lineEdit_2))
...
def CheckFileExist(self, nameW: QLineEdit):
print(nameW.text())
Can one do it in python or do I need separate functions for each lineEdit