简体   繁体   English

在Visual Studio 2013中调试显示QString(Qt5)内容?

[英]Display QString (Qt5) content in Visual Studio 2013 debugging?

I used to google a lot about it. 我曾经谷歌很多关于它。

  • I enabled Debugging -> Edit and Continue in Native Only options 我启用了Debugging - > Edit and Continue in Native Only选项
  • I was trying to add Visualizers to Visual Studio 2013\\Visualizers 我试图将Visualizers添加到Visual Studio 2013\\Visualizers
  • vstools project on codeplex is not for 2013 seems like codeplex上的vstools项目似乎不适合2013年

but so far nothing helps... 但到目前为止没有任何帮助

There is an explicit, native MSVC solution without the use of plugins etc.: see my answer from here 有一个明确的本机MSVC解决方案,不使用插件等。 请参阅我的答案

Say you have QString str , then add to the debugger session watch window : 假设您有QString str ,然后添加到调试器会话监视窗口

Qt4 : Qt4

((str).d)->array,su 

for Qt5 it's slightly more complicated: 对于Qt5来说,它稍微复杂一点:

(char*)str.d + str.d->offset,su

I search this problem's answer for a long time, and final success saw the QString content by try check/uncheck mentioned options. 我长时间搜索这个问题的答案,最后的成功通过尝试检查/取消选中提到的选项来查看QString内容。 Hope can help others. 希望可以帮助别人。

display qstring content 显示qstring内容

  1. Install qt-vs-addin-msvc2013-2.0.0-beta.vsix 安装qt-vs-addin-msvc2013-2.0.0-beta.vsix
  2. Uncheck TOOLS->Debugging->Edit and Continue->Enable native Edit and Continue 取消选中工具 - >调试 - >编辑并继续 - >启用本机编辑并继续
    Uncheck TOOLS->Debugging->Edit and Continue->Enable native Edit and Continue 取消选中工具 - >调试 - >编辑并继续 - >启用本机编辑并继续

Managed to see QString content by disabling Debugging -> Edit and Continue 通过禁用Debugging -> Edit and Continue来管理以查看QString内容

not sure if there could be better solutions 不确定是否有更好的解决方案

I know this question is a while back but if relevant, for VS 2013 then go to 我知道这个问题有一段时间了,但如果相关的话,对于VS 2013则转到

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers"

and add Code from below link in a text file and name it qt5.natvis. 并在文本文件中添加来自以下链接的代码并将其命名为qt5.natvis。 For VS 2019 the location would be: 对于VS 2019,位置将是:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Packages\Debugger\Visualizers"

Hope this helps. 希望这可以帮助。

pastebin code for seeing qt variables in visual studio 用于在visual studio中查看qt变量的pastebin代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM