[SOLVED] How can I see qDebug messages while debugging in QtCreator


I’m making the transition from Eclipse CDT (with Qt integration plugin) to QtCreator 2.0 but there is still one thing that bother me with QtCreator :

When I debug in QtCreator, I don’t see my qDebug messages inside the Application output tab until I stop the application I’m debugging… Then they are all displayed at once which is not very useful.

With Eclipse, I don’t have this problem : the qDebug messages are displayed correctly when encountered while stepping through the source code.

I’m using both Eclipse CDT and Qt Creator under Windows. I didn’t try under Linux (which is not an option right now).


While not a complete answer, you can install DebugView (If you’re on an XP machine) to view the qDebug output while you try to figure this out.

Another solution might be considered a hack, but works quite nicely, is to simply hijack debug messages yourself:

#include <QtCore/QCoreApplication>
#include <QDebug>
#include <iostream>

void msgHandler( QtMsgType type, const char* msg )
    const char symbols[] = { 'I', 'E', '!', 'X' };
    QString output = QString("[%1] %2").arg( symbols[type] ).arg( msg );
    std::cerr << output.toStdString() << std::endl;
    if( type == QtFatalMsg ) abort();

int main(int argc, char *argv[])
    qInstallMsgHandler( msgHandler );
    QCoreApplication a(argc, argv);

    qDebug() << "Hello world.";
    qWarning() << "Uh, oh...";
    qCritical() << "Oh, noes!";
    qFatal( "AAAAAAAAAH!" );

    return a.exec();

Which would output:

[I] Hello world. 
[E] Uh, oh... 
[!] Oh, noes! 

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

This is actually a modification of some code that I use myself to send qDebug, qWarning, etc., to a log file.

Answered By – kurige

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *