Search code examples
pythonpyqt5

Disconnect pyqt signal from connected function


I've connected a returnPressed signal of QLineEdit to a function but i don't know how to disconnect it from the connected one.

self.usernameLineEdit.returnPressed.connect(self.send_code_clicked)

I would be pleased if you can help me. Thanks

I've tried to disconnect with the following codes but it didn't work

self.confirmationCodeLineEdit.returnPressed.disconnect() self.confirmationCodeLineEdit.returnPressed.disconnect(self.send_code_clicked)


Solution

  • To disconnect a signal from a function in PyQt, you need to use the disconnect signal's method of the same object it was connected to.

    self.usernameLineEdit.returnPressed.disconnect(self.send_code_clicked)