[Qt-interest] install message handler

Sajjad dosto.walla at gmail.com
Thu Sep 2 11:28:17 CEST 2010


Hello forum,


I am trying all my debug output to a file and i tried using the
qInstallMsgHandler.the function pointer contains the following definition:

************************************************

#include "Util.h"

#include <iostream>

void debugMessageHandler(QtMsgType type, const char *msg)
{
    static QFile *file = new QFile(":/H3D/debugOut.txt");

    if(!file->exists())
        std::cout << "file does not exist" << std::endl;
    else
        std::cout << "File is there" << std::endl;

    QTextStream out(file);
    switch(type)
    {
    case QtDebugMsg:
        out << "Debug" << QString(msg);
        break;
    }
}

********************************************************************


I install the handler in the main function and  it is supposed to be
functional from anywhere in the project, right?


After every debug output with qDebug() i chcek the contents of the file and
it is still empty.


Is there anything i am missing in the process?



Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100902/d07c997e/attachment.html 


More information about the Qt-interest-old mailing list