Thanks.
Let me be more specific:
*** questions below ***
I call:
qInstallMsgHandler(myMsgHandler);
to install my own message handler, which follows:
void myMsgHandler(QtMsgType type , const char *msg)
{
QString text;
if (strstr(msg, "Object::connect:") != NULL)
{
return;
}
switch (type)
{
case QtDebugMsg:
text = QString ("Debug: %1\n").arg(msg);
break;
case QtWarningMsg:
text = QString ("Warning: %1\n").arg(msg);
break;
case QtCriticalMsg:
text = QString ("Critical: %1\n").arg(msg);
break;
case QtFatalMsg:
text = QString ("Fatal: %1\n").arg(msg);
break;
}
// Display a message to the user
if (this thread is gui thread) *** How do I get the thread to see if this is a GUI thread? ***
{
QMessageBox::information(NULL, QString("Error"), text); // this only works if this handler was called from a GUI thread
}
else
{
*** how to display error to user from a non-gui thread? ***
}
#ifndef NDEBUG // when in debug mode, do this
#ifdef WINDOWS
OutputDebugStringA(text.toAscii().data()); // this works if we are in debug
#else // non-windows
fprintf(stderr(text.toAscii()));
#endif
}
#endif
if (type == QtFatalMsg)
{
abort();
}
return;
}
Bookmarks