[PyQt] Keypressevent
Hans-Peter Jansen
hpj at urpla.net
Wed Sep 8 13:17:00 BST 2010
[Resend to list also]
On Wednesday 08 September 2010, 11:06:59 lucaberto at libero.it wrote:
> hello i need to intercept the return and the enter key in a plaintextedit
> and i have write this
> def keyPressEvent(self, event):
> self.plainTextEdit.keyPressEvent(event)
> if event.key() == QtCore.Qt.Key_Return :
> print ' return'
> elif event.key() == QtCore.Qt.Key_Enter :
> print ' enter'
>
> but the def keyPressEvent is called only if i press for ex blocnum and
> not when i push normal letter or return or enter.
> Can you explain me how to do it
You need to place your event handler in a subclass of QPlainTextEdit and
read the doc of QKeyEvent..
Pete
More information about the PyQt
mailing list