Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. void debugMessageHandler( QtMsgType type, const char *msg ){
  2. if(QString(msg).contains( "The message you can see in the console" )){
  3. int breakPointOnThisLine(0);
  4. }
  5.  
  6. switch ( type ) {
  7. case QtDebugMsg:
  8. fprintf( stderr, "Debug: %sn", msg );
  9. break;
  10. case QtWarningMsg:
  11. fprintf( stderr, "Warning: %sn", msg );
  12. break;
  13. case QtFatalMsg:
  14. fprintf( stderr, "Fatal: %sn", msg );
  15. abort();
  16. }
  17. }
  18.  
  19. #include <csignal>
  20. #include <QtCore/QCoreApplication>
  21. using namespace std;
  22.  
  23. struct CleanExit{
  24. CleanExit() {
  25. signal(SIGINT, &CleanExit::exitQt);
  26. signal(SIGTERM, &CleanExit::exitQt);
  27. signal(SIGBREAK, &CleanExit::exitQt) ;
  28. }
  29.  
  30. static void exitQt(int sig) {
  31. QCoreApplication::exit(0);
  32. }
  33. };
  34.  
  35.  
  36. int main(int argc, char *argv[])
  37. {
  38. CleanExit cleanExit;
  39. QCoreApplication a(argc, argv);
  40. return a.exec();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement