QtCreator: qDebug Messages Not Shown

5.3k views Asked by At

I am currently using QT Creator 3.2.1 with Qt 5.3.2 (as required by my current project) on Windows 7 (64 bits, Ultimate). I am currently working on a GUI project

I am unable to see any qDebug messages in the Application Output window despite already done the following:

  1. Having the appropriate QDebug code
  2. Building the project in Debug mode
  3. Using "CONFIG += openssl-linked" "CONFIG += console" as additional arguments for building the project
  4. Not defining QT_NO_DEBUG_OUTPUT at all
  5. Confirming that I have a debugger (GDB from MinGW 4.8.2 32 bit installed during installing QtCreator)

May I know what else should I try? Thanks!

2

There are 2 answers

1
Alexander V On BEST ANSWER

I don't get any debug messages supposed to be printed out by qDebug() in Qt Creator? What could be the reason for that?

It is common to redefine the standard Qt debug output in Qt apps via the custom log message handler but we can still take care of making debug messages to reach the debug console:

// example for custom message handler
void customLogHandler(QtMsgType type, const QMessageLogContext& context,
                      const QString& msg)
{
   // send the data to log file via the other thread
   emit writeToFile(type, context, msg);

   // now output to debugger console
#ifdef Q_OS_WIN
    OutputDebugString(text.toStdWString().c_str());
#else
    std::cerr << text.toStdString() << std::endl;
#endif
}

void main()
{
   // custom handler start
   qInstallMessageHandler(&customLogHandler);

   // other app initializations
}
4
Ingo Mi On

This did it for me on Arch Linux

Qt creator > Tools > Options > Kits, select your kit, find Environment, click change and add:

   QT_ASSUME_STDERR_HAS_CONSOLE=1

Now the Message can be printed in the Application Output with something like that:

   qDebug() << "User clicked on the button!";

Screenshot on how to enable qDebug message

And than you should see something in the program like so:

qDebug output screenshot