[英]View contents of QStandardItemModel in Locals View in Qt Creator
Is there a way to view the data stored in a QStandardItemModel
object by using the Locals and Expressions window in Qt Creator, in order to monitor their values while debugging? 有没有一种方法可以使用Qt Creator中的“本地和表达式”窗口来查看存储在QStandardItemModel
对象中的数据,以便在调试时监视其值?
I can see the contents of arrays in the Locals window, but for a QStandardItemModel
the representation does not show me the data inside: Image of Qt Creator Locals Window showing a QStandardItemModel . 我可以在Locals窗口中看到数组的内容,但是对于QStandardItemModel
,表示形式不会向我显示内部数据: 显示QStandardItemModel的Qt Creator Locals窗口的图像 。
I am using Qt Creator version 4.0.3 and Qt version 5.7.0. 我正在使用Qt Creator 4.0.3版和Qt 5.7.0版。
I have already tried the following, but they did not help: 我已经尝试了以下方法,但是它们没有帮助:
I have also tried adding myQStandardItemModel->item(0,0)->text()
to the Expressions window, but this gives a value of <no such value>
. 我也尝试将myQStandardItemModel->item(0,0)->text()
到“表达式”窗口,但这给出的值<no such value>
。 However, this expression does work if I place it directly in the code, assigning it to a temporary variable. 但是,如果我将其直接放置在代码中并将其分配给临时变量,则该表达式确实可以工作。 Although I can debug using this technique, it forces me to add temporary variables to my code and re-compile each time that I discover a need to check a QStandardItemModel
- is there a faster way? 尽管我可以使用这种技术进行调试,但它迫使我在发现需要检查QStandardItemModel
每次添加临时变量到我的代码并重新编译-有没有更快的方法?
I have now found that if I switch from using Qt Creator to using Microsoft Visual Studio 2015 to debug my code, I am able to see the contents of a QStandardItemModel
in the Locals window during break mode. 现在,我发现,如果我从使用Qt Creator切换到使用Microsoft Visual Studio 2015调试代码,则可以在中断模式下的“本地”窗口中查看QStandardItemModel
的内容。 The data of the first item in the QStandardItemModel
can be found at: QStandardItemModel
第一项的数据可以在以下位置找到:
myQStandardItemModel / QAbstractItemModel / QObject / d_ptr / [Raw View] / d /
[QStandardItemModelPrivate] / root / [Raw View] / d / d_ptr / [Raw View] / d / children /
[0] / d_ptr / [Raw View] / d / values / [0] / value
The follow screenshot illustrates this: 以下屏幕截图说明了这一点:
. 。
I also tried compiling the code in Qt Creator using the Microsoft Visual C++ compiler and debugging using the CDB debugger from the Windows SDK. 我还尝试使用Microsoft Visual C ++编译器在Qt Creator中编译代码,并使用Windows SDK中的CDB调试器进行调试。 However, although this did provide more debugging information in the Locals window about a QStandardItemModel
than MinGW had done, I could not find the actual text data within each item of the QStandardItemModel
. 但是,尽管与MinGW相比,它确实在Locals窗口中提供了有关QStandardItemModel
更多调试信息,但我无法在QStandardItemModel
每个项目中找到实际的文本数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.