QtCreator:未显示 qDebug 消息

QtCreator: qDebug Messages Not Shown

我目前在 Windows 7(64 位,旗舰版)上使用 QT Creator 3.2.1 和 Qt 5.3.2(根据我当前项目的要求)。我目前正在从事 GUI 项目

我无法在应用程序输出中看到任何 qDebug 消息 window 尽管已经完成了以下操作:

  1. 拥有适当的 QDebug 代码
  2. 在调试模式下构建项目
  3. 使用 "CONFIG += openssl-linked" "CONFIG += console" 作为构建项目的附加参数
  4. 根本没有定义 QT_NO_DEBUG_OUTPUT
  5. 确认我有一个调试器(在安装 QtCreator 期间安装了来自 MinGW 4.8.2 32 位的 GDB)

我可以知道我还应该尝试什么吗?谢谢!

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

通过自定义日志消息处理程序在 Qt 应用程序中重新定义标准 Qt 调试输出是很常见的,但我们仍然可以处理使调试消息到达调试控制台的问题:

// 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
}

This 在 Arch 上为我完成了 Linux

Qt creator > 工具 > 选项 > 工具包,select 你的工具包,找到环境,点击更改并添加:

   QT_ASSUME_STDERR_HAS_CONSOLE=1

现在可以在应用程序输出中打印消息 用类似的东西:

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

你应该会在程序中看到如下内容: