BlackBerry 10 Cascades – console.log() and qDebug() output

This snippet of code will allow you to see the output of qDebug and console.log from the Momentics IDE when developing for BlackBerry 10.

First we need to add this function to the main.cpp file:


void myMessageOutput(QtMsgType type, const char* msg){
Q_UNUSED(type);
fprintf(stdout, "%s\n", msg);
fflush(stdout);
}

Inside our main() function, add this:

//Message Handler
qInstallMsgHandler(myMessageOutput);

Now you will be able to see the output in the IDE while debugging your application, make sure to comment the qInstallMsgHandler line before exporting the Release version of your application.

Leave a Reply

Your email address will not be published. Required fields are marked *