How to handle keypress events in a Qt console application?
问题 For example, that when you press "Esc", the application ends. 回答1: Qt doesn't handle console events, it can just read \n -terminated lines from the console. You need to use native APIs or other libraries (curses). 回答2: Here is a workaround for linux. Using these posts Capture characters from standard input without waiting for enter to be pressed https://stackoverflow.com/a/912796/2699984 I've made it like this: ConsoleReader.h #ifndef CONSOLEREADER_H #define CONSOLEREADER_H #include <QThread>