How to configure qt creator to show C++ codes rath

2020-06-16 04:03发布

问题:

Yesterday I had done a lot of things like updating GCC,Clang and reinstalling Qt Creator.Today when debugging my codes step by step, the debugger was showing the disassembler rather than the C++ codes I wrote. Pressing F10 or F11, the debugger was moving in disassembler not in .cpp nor .h files I wrote. F11 can only go into the library files but never into the files I wrote.

The arrow appeared in disassembler:

Rather than in main.cpp:

How to configure Qt Creator such that the debugging arrow tracks each line in the C++ codes?

回答1:

For others who also had this problem but none of the solutions above worked (like me), I found out that the issue for me was simply happening because my project was inside of a directory with special characters (/home/fabio/criação/project) the criação folder seems to have caused the problem. After I changed to /home/fabio/Desktop/project it stop happening.



回答2:

I ran into a very similar problem debugging code built with the clang toolset in qtcreator, and this answer fixed me up:

gdb doesn't find source files compiled by clang++

You can quickly check if that solution will work for you by navigating to the root of your solution in a shell window and then invoking qtcreator from there...set a break point in main() and try debugging - if it stops and shows source in main.cpp, it's quite likely this is the problem.

If that does work for you, there are probably several better ways to implement the permanent solution suggested by https://stackoverflow.com/users/1632219/rene, but the method that worked for me was to modify my qmake mkspec file for the clang toolset. On my system, it lives in /usr/local/Trolltech/Qt-4.8.5/mkspecs/common/clang.conf, so all I had to do was put a clang invoker script with 'clang++ "$@"' in ~/bin/clang-compile and then set QMAKE_CXX in the mkspec to clang-compile. With that change, when the clang toolset is selected, qmake builds make files that use clang-compile instead of clang++ and then debugging works everywhere.



回答3:

At last, I found that it was Clang that had caused this problem. After changed the kit back to using gcc, it just worked fine. But not sure whether it's Clang's fault or that the script Qt produced for compiling has any problem. Anyway just put the answer here in case anyone else who might encounter the same situation.



回答4:

Goto "Help->About Plugins" and check the "ClangCodeModel" and restart QT.

There is a bug in version Qt 5.6.1 (MSVC 2013, 32 bit) QT Creator4.0.3. In debug mode put your breakpoint. Then hit the step into(F11) it will start debugging now. To go to your code hit the step-over(F10) until you come to the code page.

I have searched about this problem but nothing worked. Some solution, i didn't get. This is very annoying issue.