I am developing an application using Qt Creator. It is version 3.1.2 based on Qt 5.3.1 (MSVC 2010, 32bit) running on Win 7. I have been working on this project for about 9 months. Before that I had no experience with Qt and almost none with C++. So I'm very inexperienced with resolving some issues I run into. This is one of them.

I picked up some code a few months ago that allows me to put the output of QDebug in a file rather than the console. I added it to a project at the time and it worked great. I am now attempting to put the same code in a new project and I am encountering build errors. The code goes in the main.cpp module. Here is the code:

Qt Code:
  1. #define MY_ASSERT(c) if (c == false) ;
  2. #define MY_ASSERT_X(c, where, what) if (c == false) ;
  3.  
  4. void myLogger(QtMsgType type, const QMessageLogContext &context, const QString &msg)
  5. {
  6. QFile file("E:/temp/logs/QDebug."+QDate::currentDate().toString("yyyyMMdd")+".log.txt");
  7.  
  8. MY_ASSERT(file.open(QIODevice::Append | QIODevice::Text));
  9.  
  10. QTextStream out(&file);
  11. out << QTime::currentTime().toString("hh:mm:ss.zzzz ");
  12.  
  13. out << context.file << "::" << context.function << "::" << context.line;
  14.  
  15. switch (type)
  16. {
  17. case QtDebugMsg: out << " DBG "; break;
  18. case QtWarningMsg: out << " WRN "; break;
  19. case QtCriticalMsg: out << " CRT "; break;
  20. case QtFatalMsg: out << " FTL "; break;
  21. }
  22.  
  23. out << " " << msg << '\n';
  24. out.flush();
  25. }
To copy to clipboard, switch view to plain text mode 

And then in the function main I put

Qt Code:
  1. qInstallMessageHandler(myLogger);
To copy to clipboard, switch view to plain text mode 

In the new project I get the following errors:

C:\Qt\Qt5.3.1\5.3\msvc2010_opengl\include\QtCore\q datetime.h:122: warning: C4003: not enough actual parameters for macro 'min'
C:\Qt\Qt5.3.1\5.3\msvc2010_opengl\include\QtCore\q datetime.h:122: error: C2589: '(' : illegal token on right side of '::'
C:\Qt\Qt5.3.1\5.3\msvc2010_opengl\include\QtCore\q datetime.h:122: error: C2059: syntax error : '::'
The main difference between the two projects is that the one that works is a console application and uses QCoreApplication. The one that doesn't work is a widgets application and uses QApplication.

What do I need to do to get this code in the QWidgets application to work?