简体   繁体   中英

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?

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 .

I am using Qt Creator version 4.0.3 and Qt version 5.7.0.

I have already tried the following, but they did not help:

  • Right-clicking the object in the Locals window, choosing 'Change Value Display Format' and setting it to Raw Data, String or Array of 10 Items;
  • Checking that 'Load System GDB Pretty Printers' is off under Tools / Options.

I have also tried adding myQStandardItemModel->item(0,0)->text() to the Expressions window, but this gives a value of <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?

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. The data of the first item in the QStandardItemModel can be found at:

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:

VS2015 Locals中的QStandardItemModel图像 .

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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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