教程:Qt Quick 调试
本教程使用New Project 向导生成的示例应用程序,演示如何在Debug 模式下调试Qt Quick 应用程序。有关该示例应用程序的教程,请参阅《教程:Qt Quick 应用程序》。
有关所有可用选项的更多信息,请参阅《调试Qt Quick 项目》。
该示例应用程序演示了 Qt Quick。在Qt Creator 中打开示例项目以进行调试:
- 要查看响应按钮点击的代码,请在
Main.qml中,点击触发onClicked信号处理程序的那一行代码的行号与窗口边框之间的区域,设置断点。
红色圆圈表示该行号处现已设置了断点。
- 转到Debug >Start Debugging >Start Debugging of Startup Project ,或按F5 键。
- 应用程序启动后,选择“Light mode ”以切换模式。

- 当调试器遇到断点时,它会中断应用程序。Qt Creator 会以调用堆栈跟踪的形式显示导致当前位置的嵌套函数调用。

- 在工具栏上选择“
”(Step Into ),或按F11 键,以逐步进入堆栈中的代码。 - 在“Locals ”视图中检查局部变量。逐步执行代码,观察视图中的信息如何变化。
检查局部变量
在“Locals ”视图中,探索运行时的对象结构。

双击属性的值以更改它。
删除断点
要删除断点,请右键单击该断点,然后选择“Delete Breakpoint ”。
将应用程序置于最前
转到“Debug ” > “Show Application on Top ”,以便在与调试器交互时保持应用程序可见。
另请参阅 《教程:Qt Quick 应用程序》和《调试Qt Quick 项目》。
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.