How to redirect qDebug, qWarning, qCritical etc output?

You’ve to install a message handler using qInstallMsgHandler function, and then, you can use QTextStream to write the debug message to a file. Here is a sample example: #include <QtGlobal> #include <stdio.h> #include <stdlib.h> void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stderr, “Debug: … Read more