Variables in Locals and Expressions not accessible in QT Creator

 ̄綄美尐妖づ 提交于 2019-12-09 17:53:36

问题


If I try to debug my C++ program in QT Creator the Locals and Expressions window shows me the variables in the program. However all the values show "< not accessible >".

Screenshot:

How do I get the values to show? I can print the values out with cout so I know they are initialized.

Edit: It seems like it only applies to strings

Specs/other:

  • Windows 8, 64bit
  • QT 5.2.0
  • MinGW 32bit, I think 4.8
  • QT Creator 3.0.0

回答1:


Try to remove the checkmark at Tools/Options/Debugger/GDB/Load system GDB pretty printers, and see whether this makes a difference.




回答2:


Solved:

For composite types (std::string and other classes) it doesn’t automatically convert to some default type (e.g. std::string to char*); so what you need to do it right-click on a value, then select the submenu Change local display format-> Raw structure, and then keep opening the symbol until you get something meaningful (when possible). E.g. for std::string, after you change to “Raw structure”, you get your actual string (by clicking the “+” sign to the left of your symbol) in: _M_dataplus->_M_p

Note that you can “Change local display format” for one symbol (the one you selected) or for all symbols of that type (e.g. you select a std::string, then all std::strings change to Raw structure)

From this link: http://qt-project.org/forums/viewthread/36121/

Credit goes to Gyll.



来源:https://stackoverflow.com/questions/20610186/variables-in-locals-and-expressions-not-accessible-in-qt-creator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!