[Interest] Intercept key bindings for QTextEdit subclass

Josh jnfo-d at grauman.com
Tue Apr 1 20:59:01 CEST 2025


Hi,

I have a QTextEdit subclass that I want to intercept the key bindings for 
(like Ctrl-X, etc.). If I reimplement QTextEdit::keyPressEvent(QKeyEvent 
*k) I can get the keys and do whatever with them. But I actually want to 
ignore the event so it gets passed up and I can add it as a menu action 
item shortcut to the main window. But calling k->ignore(); and then 
returning in keyPressEvent() doesn't allow the main window to use the 
shortcut. Is there a way that the main window can see those shortcut keys?

Josh


More information about the Interest mailing list