QAudioRecorder's internal states are managed through signals and slots. This requires a running event loop;
QCoreApplication should be used for console applications.
QApplication should be used for GUI applications.
In your above example, the MainWindow isn't even necessary, it's the app.exec() where the magic is happening.