반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <QApplication> #include <QtDebug> #include <QFile> #include <QTextStream> void myMessageHandler(QtMsgType type, const char *msg) { QString txt; switch (type) { case QtDebugMsg: txt = QString("Debug: %1").arg(msg); break; case QtWarningMsg: txt = QString("Warning: %1").arg(msg); break; case QtCriticalMsg: txt = QString("Critical: %1").arg(msg); break; case QtFatalMsg: txt = QString("Fatal: %1").arg(msg); abort(); } QFile outFile("log"); outFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&outFile); ts << txt << endl; } int main( int argc, char * argv[] ) { QApplication app( argc, argv ); qInstallMsgHandler(myMessageHandler); ... return app.exec(); } |
반응형
'02.윈도우 > Qt' 카테고리의 다른 글
Qt에서 현재경로 가져오기 (0) | 2014.03.10 |
---|---|
Drag&Drop Event (0) | 2014.03.07 |
QFontMetrics elidedText (0) | 2014.02.24 |
Qt Creator Color Scheme & KeyboardSetting (0) | 2014.02.19 |
Qt 실행시간 체크 - QTime (0) | 2014.02.19 |