unit-testing - Qt单元测试中使用qDebug

我想在 Qt 单元测试中使用 qDebug,我已经编写了 qDebug 的代码,但它没有被显示 我什至用过

ctest -R alkimia-alkinvoice -VV

但即使这样也只能显示错误的来源位置。 但我需要使用 qDebug 来获取有关该错误的更多信息

最佳答案

引用 qDebug() 的文档..

Calls the message handler with the debug message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the console, if it is a console application; otherwise, it is sent to the debugger. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.

我假设您在 Windows 下运行,如果不正确,请见谅。 Windows 下的 qDebug() 输出被转换为 Win32 OutputDebugString() API 调用。如果您在可以连接到该 API 的调试器/IDE 下运行,那么您应该会在该程序的一个窗口中看到调试输出。

如果您将 CONFIG+=console 添加到您的 .pro 文件并从控制台重建/运行您的程序,您应该会看到调试输出。

https://stackoverflow.com/questions/6960575/

相关文章:

c# - 如何将整数数组转换为内存流?

csv - 如何使用 RSqlite 将 sqlite 导出为 CSV?

regex - Nginx:如何重写除图像以外的所有 URL?

python - os.walk 某些文件类型到现有的 ZipFile?

python - 创建 StringToSign

google-maps - 我如何知道哪个标记正在被 Google Maps API 拖动事件拖动?

eclipse - 无法在 Eclipse + EPIC 中查看本地

iis - Windows 身份验证通过反向代理问题

web-services - spring web services - 如何在方法端点中获取字符串

eclipse - 如何从 Eclipse 类路径中排除一个 jar?