Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8152931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:51:17+00:00 2026-06-06T15:51:17+00:00

In Qt Creator, I could view the qDebug() , qWarning() etc. output directly in

  • 0

In Qt Creator, I could view the qDebug(), qWarning() etc. output directly in the IDE. How could I do this in Visual Studio?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:51:18+00:00Added an answer on June 6, 2026 at 3:51 pm

    When you run the program with an attached debugger, it will show in the Output Window of Visual Studio, but for Debug purposes i often redirect the debug output to some kind of nice log window, which you can do by using the function qInstallMsgHandler:

    the code that i use:

    #include <qapplication.h>
    #include <qwidget.h>
    #include <qplaintextedit.h>
    #include <qmetaobject.h>
    #include <qthread.h>
    #include <qboxlayout.h>
    #include <qdatetime.h>
    #include <qdebug.h>
    #include <cstdio>
    #include <cassert>
    
    
    QWidget         *DEBUG_MESSAGE_DISPLAY_WIDGET   = NULL;
    QPlainTextEdit  *DEBUG_MESSAGE_DISPLAY_TEXTEDIT = NULL;
    void setupDebugDisplay();
    void debugMessageDisplayFunc(QtMsgType type, const char *msg);
    
    int main( int argc, char* argv[] )
    {
      QApplication a( argc, argv );
      a.setQuitOnLastWindowClosed( true );
      setupDebugDisplay();
      // your code here.... e.g:
      //   YourMainWindow mainWindow;
      int ret = a.exec();
      delete DEBUG_MESSAGE_DISPLAY_WIDGET;
      return ret;
    }
    
    void setupDebugDisplay()
    {
        QWidget *widget = new QWidget();
        widget->setWindowTitle( "Debug Log" );
        widget->setAttribute( Qt::WA_QuitOnClose, false ); //quit only when mainwindow is closed
        QBoxLayout* layout = new QVBoxLayout();
        widget->setLayout( layout );
        QPlainTextEdit *textEdit = new QPlainTextEdit( widget );
        QFont font = QFont( "Monospace" );
        font.setStyleHint(QFont::TypeWriter);
        textEdit->setFont( font );
        textEdit->setReadOnly(true);
        layout->addWidget( textEdit );
        widget->show();
        DEBUG_MESSAGE_DISPLAY_WIDGET   = widget;
        DEBUG_MESSAGE_DISPLAY_TEXTEDIT = textEdit;
        qInstallMsgHandler(debugMessageDisplayFunc);
    }
    
    void debugMessageDisplayFunc(QtMsgType type, const char *msg)
    {
      bool do_abort = false;
      const char* msgTypeStr = NULL;
      switch (type) {
        case QtDebugMsg:
          msgTypeStr = "Debug";
          break;
        case QtWarningMsg:
          msgTypeStr = "Warning";
          break;
        case QtCriticalMsg:
          msgTypeStr = "Critical";
          break;
        case QtFatalMsg:
          msgTypeStr = "Fatal";
          do_abort = true;
        default:
          assert(0);
          return;
      }
      QTime now = QTime::currentTime();
      QString formattedMessage = 
        QString::fromLatin1("%1 %2 %3")
        .arg(now.toString("hh:mm:ss:zzz"))
        .arg(msgTypeStr).arg(msg);
      // print on console:
      fprintf( stderr, "%s\n", formattedMessage.toLocal8Bit().constData() );
      // print in debug log window
      {
    
        bool isMainThread = QThread::currentThread() == QApplication::instance()->thread();
        if(DEBUG_MESSAGE_DISPLAY_TEXTEDIT)
        {
          if( isMainThread )
            DEBUG_MESSAGE_DISPLAY_TEXTEDIT->appendPlainText( formattedMessage );
          else // additional code, so that qDebug calls in threads will work aswell
            QMetaObject::invokeMethod( DEBUG_MESSAGE_DISPLAY_TEXTEDIT, "appendPlainText", Qt::QueuedConnection, Q_ARG( QString, formattedMessage ) );
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using DynamicPDF creator, Visual Studio 2010, and IIS 7. On my local
I just completed an exercise for this text and was wondering if this could
I'm trying to import some working Visual C++ code into Qt Creator and I'm
This question could bring a lot of opinions to the table, but what I
Could someone explain this behaviour to me? If you execute the snippet at the
Currently I am using Sun Java Studio Creator 2 Update 1. I would like
I have been using Qt Creator as an IDE for some C++ project (non-QT)
In this video :http://www.youtube.com/watch?v=BES9EKK4Aw4 Notch (minecraft's creator) is doing what he refers to as
I'm using Qt Creator 4.5 with GCC 4.3 and I'm having the following problem
I have Qt Creator on my mac. I downloaded the Qt sdk sources, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.