View Array contents in QtCreator

梦想的初衷 提交于 2019-12-11 05:28:51

问题


Is it possible to view the contents of an array in Qt Creator when debugging?

It seems to detect that my array is an array and not a pointer. Additionally, an arrow becomes available for me to click on as if to expand - but nothing shows after that.

When I tried it on std::vector, Qt Creator managed to display the contents as expected.

PS: I found this old post about viewing array contents, but its over 2 years old and does not seem relevant anymore.


回答1:


If you mean a regular array like

int array[20] 

you can add a 'watch' manualy in this form:

(int[20])array

You can add it in your variables view.




回答2:


you can veiw the content of array by going to local and expression part

and click right and sellect add new expression evaluator then add your array between watcher like

(int(*)[10])arr;

or

(int[10])(*arr);

now you can see each element at your array

this is faster than entering each element manual by adding *(arr + element number) at add new expression evaluator this is too bad if you have array of 1000 element or more



来源:https://stackoverflow.com/questions/18966038/view-array-contents-in-qtcreator

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