26
|
1 |
#include <QApplication>
|
|
2 |
#include <Mainwindow.h>
|
|
3 |
#include<qfile.h>
|
|
4 |
#include<qtextstream.h>
|
|
5 |
|
|
6 |
void debugOutput(QtMsgType type, const char *msg)
|
|
7 |
{
|
|
8 |
QFile logFile("c://data//TestAppLog.txt");
|
|
9 |
Q_ASSERT(logFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append ));
|
|
10 |
QTextStream stream(&logFile);
|
|
11 |
|
|
12 |
switch (type)
|
|
13 |
{
|
|
14 |
case QtDebugMsg:
|
|
15 |
stream<<msg<<"\n";
|
|
16 |
break;
|
|
17 |
|
|
18 |
case QtWarningMsg:
|
|
19 |
stream<<"Warning: ";
|
|
20 |
stream<<msg<<"\n";
|
|
21 |
break;
|
|
22 |
|
|
23 |
case QtCriticalMsg:
|
|
24 |
stream<<"Critical: ";
|
|
25 |
stream<<msg<<"\n";
|
|
26 |
break;
|
|
27 |
|
|
28 |
case QtFatalMsg:
|
|
29 |
stream<<"Fatal: ";
|
|
30 |
stream<<msg<<"\n";
|
|
31 |
break;
|
|
32 |
|
|
33 |
default:;
|
|
34 |
}
|
|
35 |
}
|
|
36 |
|
|
37 |
int main(int argc,char *argv[])
|
|
38 |
{
|
|
39 |
qInstallMsgHandler(debugOutput);
|
|
40 |
QApplication app(argc,argv);
|
|
41 |
MainWindow *mainWnd = new MainWindow();
|
|
42 |
mainWnd->showMaximized();
|
|
43 |
return app.exec();
|
|
44 |
}
|