I’m trying to write some unittests for my QPlainTextEdit based widget, so I need to send fake key presses to it.
I can successfully send ordinary a-z key presses, but when I try to send a new line my keyPressEvent handler doesn’t receive the key press.
In the code below the first sendEvent is working fine, but the second isn’t. Where could the problem be?
for char in "import django":
global_objects.app.sendEvent(editor, QtGui.QKeyEvent(QtCore.QEvent.KeyPress, ord(char), QtCore.Qt.NoModifier, char))
global_objects.app.sendEvent(editor, QtGui.QKeyEvent(QtCore.QEvent.KeyPress, QtCore.Qt.Key_Return, QtCore.Qt.NoModifier))
Thanks,
Andrew
This problem was caused by me filtering the event else where in my code. Oops.