The method you're looking for is called keyPressEvent
, not KeyPressEvent
.
It seems that your QLineEdit
is stealing your KeyPress
events. If handling the enter key from the line edit is all you want to do, you could connect the returnPressed
signal to self.fun
:
self.text.returnPressed.connect(self.fun) # in PySide
Otherwise, you will have to mess around with event filters. I'll try posting some code later on.
Your final edit made it clearer. You can safely drop keyPressEvent
and just use:
self.text.returnPressed.connect(self.fun)
self.button.clicked.connect(self.fun)
What a messy answer this turned out to be :)