// .h - filevoid myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);// .cpp - filevoid myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg){ QFile outFile(QCoreApplication::applicationDirPath()+"\\"+QCoreApplication::applicationName()+".log"); outFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&outFile); ts << QDateTime::currentDateTime().toString("dd/MM/yyyy (HH:mm:ss) : ") << msg << endl; if (type == QtFatalMsg) abort();}// in main() { }qInstallMessageHandler(myMessageHandler);w.show();return a.exec();
C++ (Qt)mainy::~mainy() { // qDebug("DESTROYED");}