c++ - MessageHandler Qt -


i create qtmsgtype. wrote messagehandler handles default types. qdebug() qtdebugmsg, qwarning() qtwarningmsg etc.

in qt source:

enum qtmsgtype { qtdebugmsg, qtwarningmsg, qtcriticalmsg, qtfatalmsg, qtsystemmsg = qtcriticalmsg }; 

my messagehandler registered qinstallmsghandler:

void messagehandler(qtmsgtype type, const qmessagelogcontext&, const qstring& msg) {     switch (type){     case qtdebugmsg:    outputmessagehandler::gethandler()->debug(msg);   break;     case qtwarningmsg:  outputmessagehandler::gethandler()->warning(msg); break;     case qtcriticalmsg: outputmessagehandler::gethandler()->error(msg);   break;     case qtfatalmsg:    outputmessagehandler::gethandler()->fatal(msg);   break;     } } 

i have qmycustommessage() mycustommsg such handler catches catches qdebug() don't know how that. there way achieve that? in advance.

i doubt can define custom message other listed in qtmsgtype enum. can distinguish messages prefixing them in special way. example, in message handler can write:

void messagehandler(qtmsgtype type, const char *msg)  {      switch (type) {      case qtdebugmsg:          qstring strmessage(msg);          if (strmessage.startswith("mycustommessage") {              // handle messages here.          }          break;      default:          break;      }  } 

and in code, can send messages this:

qdebug() << "mycustommessage" << "this special message send"; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -