Use Qt Creator debugging function

Use Qt Creator debugging function

In Qt Creator, debugging is a very important function. It helps us find bugs in programs and fix them. In addition to basic breakpoint settings, Qt Creator also provides a powerful debugging assistant that can help us debug more efficiently. Let us explore how to use the Qt Creator debugging assistant!

First, open a project in Qt Creator and place the cursor on the line of code that needs to be debugged. Select "Debug" -> "Enable Debug Assistant" in the menu bar, or press the shortcut key "Ctrl+Shift+D".

Next, a Debug Assistant window will appear. In this window, we can choose different debugging assistants to help us analyze the operation of the program. For example, we can select "Memory View" to view the distribution of the program in memory; select "Thread Status" to view the status of different threads in the program, etc.

Next, let's look at a simple example. Suppose you have the following code:

#include

using namespace std;

int main()

{

int a = 10;

int b = 20;

int c = a + b;

cout << "a + b = " << c << endl;

return 0;

}

Now we place the cursor on the line "int c = a + b;" and enable the debug assistant. Then, we select the debugging assistant "Monitor", click "Add Expression", enter "c" and press Enter. Next, we start executing the program.

When the program runs to the line "int c = a + b;", we can see the value of "c" is 30 in the "Watch" window. Next, we can execute the code line by line with the F10 key ÿ

Guess you like

Origin blog.csdn.net/Jack_user/article/details/132285882