over 3 years ago

Just use some simple steps can let you check debug messages!

  1. Open the main.cpp in your project. Only need to add two code snippets!

  2. First: Insert this before int main

    void myMessageOutput(QtMsgType type, const char* msg) 
    

    {
    std::fprintf(stdout, "%s\n", msg);
    std::fflush (stdout);
    }

  3. Second:Inset snippet after Application app(argc, argv);

    qInstallMsgHandler(myMessageOutput);
    
  4. Here are the whole code snippets

    void myMessageOutput(QtMsgType type, const char* msg) 
    {
        std::fprintf(stdout, "%s\n", msg);
        std::fflush(stdout);
    }
    Q_DECL_EXPORT int main(int argc, char **argv) 
    {
        Application app(argc, argv);
        qInstallMsgHandler(myMessageOutput);
    
        // localization support
        QTranslator translator;
        QString locale_string = QLocale().name();
        QString filename = QString( "YourApp_%1" ).arg( locale_string );
        if (translator.load(filename, "app/native/qm")) 
        {
            app.installTranslator( &translator );
        }
        new YourApp(&app);
        return Application::exec();
    }
    

Enjoy all your dubeg messages! ^^

← BlackBerry Z5 & Kopi Smaato - Advertisement service for BlackBerry 10 Cascades Apps →
 
comments powered by Disqus