测试与调试

Qt 提供了各种功能来帮助您开发高质量的代码。其中有些功能可帮助调试以跟踪错误,而有些测试功能则有助于防止错误的出现。

单元测试

Qt 可帮助创建单元测试,以测试接口(如类、函数或整个库)。

  • Qt Test(单元测试(又称testlib)--用于 C++ 代码单元测试的框架
  • Qt Quick Test- QML 代码单元测试框架

自动测试

Qt 本身有大量使用Qt TestQt Quick Test 框架编写的单元测试(autotests)。这些自动测试可在每个 Qt 模块源代码的tests/auto 目录中进行研究。自动测试是 Qt 开发过程中持续质量保证的重要组成部分。

使用Qt Creator

Qt Creator的完整调试工作流程支持调试 C++ 和 QML 代码,并能对代码进行剖析。

更多信息,请查阅Qt Creator 文档

调试技巧

这些页面包含在不同情况下进行调试的建议:

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.