Tutorial: Qt Quick debugging
This tutorial illustrates how to use Qt VS Tools to debug the Qt Quick tutorial application, QuickAddressBook. After you enable QML debugging for the project, set breakpoints in QML files and step through the execution of code. While in break mode, watch variables and change their values, as well as evaluate arbitrary expressions.
For more information about all the options you have, see Debugging Qt Quick Applications.
Before you start
Before you start, you have to:
Set a breakpoint
Go to File > Open > File or Solution to open the QuickAddressBook solution.
To look at the code that adds a new contact, add a breakpoint in NewAddressPopup.qml by clicking the line that implements the onClicked
signal handler and selecting Debug > Toggle Breakpoint (or pressing F9).
The red circle indicates that a breakpoint is now set on that line.
Start debugging
Go to Debug > Start Debugging or press F5.
Once the application starts, select Add to create a new address book entry. Enter a name and email address, and select Add again to add the entry to the address book.
When the debugger hits the breakpoint, it interrupts the application. Qt VS Tools displays the nested function calls leading to the current position as a call stack trace. View and change the values of local variables.
Step through code
Go to Debug > Step Into or press F11 to step into the code in the stack. The NewAddressPopup.qml file opens in the code editor at the function that creates a new address book entry.
Watch variable values
The Autos and Locals windows show a subset of local variables that Visual Studio considers possibly interesting based on the location of the breakpoint. To watch a particular variable or expression, set a watch in the Watch 1 view.
Step through the code to see how the information changes in the view.
Evaluate expressions
To execute JavaSript commands in the context of the current stack frame, open the Immediate Commands window and type the expression to evaluate.
Remove the breakpoint
To remove the breakpoint, go to Debug > Toggle Breakpoint (or press F9).
See also Cross-compile, Debug applications, Debug on Linux, and Debugging Qt Quick applications.
© 2024 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.