The main task is to define a new method in the main. cpp file where the main function is located to forward debugging information. The function is as follows:
[Cpp]
Void myMessageOutput (QtMsgType type, const char * msg ){
Std: fprintf (stdout, "% s \ n", msg );
Std: fflush (stdout );
}
Then, call qInstallMsgHandler in the main function to register the processor. The Code is as follows:
[Cpp] www.2cto.com
QInstallMsgHandler (myMessageOutput );
In this way, all the qt debugging information of this program will be output to the console, which is very convenient to use. The following is the complete code:
[Cpp]
# Include <bb/cascades/Application>
# Include <QLocale>
# Include <QTranslator>
# Include <QTextCodec>
# Include <iostream>
Using namespace bb: cascades;
Void myMessageOutput (QtMsgType type, const char * msg ){
Std: fprintf (stdout, "% s \ n", msg );
Std: fflush (stdout );
}
Int main (int argc, char ** argv ){
// This is where the server is started etc
Application app (argc, argv );
QInstallMsgHandler (myMessageOutput );
New Demo (& app );
Return Application: exec ();
}