我已经将 QPlainTextEdit 子类化并想要捕获某些键。如果按下的键不是其中之一,请继续执行默认行为(例如,添加文本)。
这是可能的,还是我也必须编程?
例子:
def keyPressEvent(self, event):
if event.key() in [16777235, 16777237, 16777234, 16777236, 16777220]: # Up, down, left, right, return.
event.ignore()
else:
event.doDefault()