开始调试
您可以通过以下方式在调试器控制下从打开的项目中启动应用程序:
- 选择
(Start Debugging of Startup Project)。
- 选择F5。
- 在定位器中输入
dr
,然后选择要调试的项目。 - 转到Debug >Start Debugging >Start Debugging of Startup Project 。
Qt Creator 如果将 设置为构建整个项目或运行应用程序,并在Build before deploying Preferences> > 中选择 ,则系统会检查编译后的应用程序是否是最新的,并重建和部署它。要调试程序而不部署,请访问 > > 。Build & Run General Always deploy before running Debug Start Debugging Start Debugging Without Deployment
调试器会接手并使用适当参数启动应用程序。
您可以在启动调试器之前或之后指定断点。更多信息,请参阅设置断点。
执行 GDB 或 CDB 命令
使用 GDB 或 CDB 作为调试后端时,可以在偏好设置>Debugger >GDB和CDB 中指定在后端和调试程序启动或连接前后执行的其他命令。
要让调试器在启动时读取用户的默认 .gdbinit 文件,请在 GDB 设置中选择Load .gdbinit file on startup 。
注意: 在调试器控制下启动 C++ 应用程序可能需要很长时间。如果使用复杂的功能,通常需要几秒到几分钟。
调试 Python 项目
对于Python项目,开始调试main.py
文件。如果遇到问题,请检查工具包选择器中的活动构建目标。
Qt Creator GDB 不支持混合模式调试,但可以将 GDB 附加到 Python 解释器,以调试相应 Python 代码的 C++ 实现。更多信息,请参见使用 调试 PySide (Linux)Qt Creator 。
调试控制台应用程序
如果需要一个控制台窗口来操作应用程序,例如因为它接受用户的控制台输入,请访问Projects >Run Settings 并选择Run in terminal 复选框。
如果控制台应用程序无法在配置的控制台中正常启动,且后续连接失败,可以使用本机 CDB 控制台诊断问题。转到首选项>Debugger >CDB >Use CDB console ,覆盖 Windows 系统环境变量中设置的控制台。请注意,本机控制台不会在应用程序退出时提示。
Copyright © The Qt Company Ltd. and other contributors. 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.