This seems as a very serious regression bug in Qt 6.2.0 on macOS. When I run the following code and when the focus is in the line edit and I press Escape key, nothing happens. No output is printed out.
If I do the same in Qt 5.15.2, text is printed indicating that Escape key has been pressed. When I try the same with Qt 6.2.0 in Windows, it also works well.
Note: The same problem is with QTextEdit and QPlainTextEdit. Other widgets may also be affected, though I have not tested them.