PDA

View Full Version : displaying QT containers



gautiery
03-17-2009, 08:15 AM
Hi

I would like to display the content of QT containers such as QMap or QList ...

Is there a way to do so ?

Thanks

PeterT-RogueWave
03-23-2009, 10:19 AM
Hello,

Unfortunately we don't have any specific directions for QMap or Qlist. One of our goals is to improve the number of STL's that we can trasnform, but I can't say with any certainty just when that might happen. We do offer a type transform scheme whee you can set up your own transform. It is a bit dense reading, but you can find the document here:

http://www.totalviewtech.com/download/download_file.php?type=TotalView%20Doc&name=ttf.pdf

It will probably help if you modify one of the current transforms, which you can find in

/<install_path>/toolworks/totalview.8.6.2-1/lib/

any of the files here with a ttf in the name is a type of transform.

Regards,

PeterT-RogueWave
12-15-2011, 08:38 AM
I should point out that this capability should be possible with C++View, which is a bit easier to understand than STL type transforms, but requires a bit of coding on the users part. We've been questioned about other Qt containers, and I'd be willing to do some work on helping those out with C++View methods if people like. But what I'd need are some very simple Qt examples of those containers being used. Say a hello world type of program for the container you would like to see transformed. Containing SOME data at least.

Cheers,

gautiery
04-10-2014, 05:37 AM
I should point out that this capability should be possible with C++View, which is a bit easier to understand than STL type transforms, but requires a bit of coding on the users part. We've been questioned about other Qt containers, and I'd be willing to do some work on helping those out with C++View methods if people like. But what I'd need are some very simple Qt examples of those containers being used. Say a hello world type of program for the container you would like to see transformed. Containing SOME data at least.

Cheers,

Hi Pete

Sorry for not answering your last comment earlier. I just did not see it. I was just checking today if there was something new concerning the debugging of QT applications since it is still painful and frustrating. QT is a wonderful and widely used library and it is too bad that there is not more support from totalview. The containers should look like stl containers in totalview. Quite often I have to modify some existing code to print intermediate results like... when we didn't have debuggers! Here is for instance a stupid program:


#include <QtCore/QtDebug>

#include <QtCore/QString>

#include <QtCore/QVector>
#include <QtCore/QList>
#include <QtCore/QSet>
#include <QtCore/QMap>

template <typename T, typename U> class MyClass {
public:
MyClass (const T& t , const U& u, int nvalues) : _t (t) {
_vectorU = QVector <U>(nvalues, u);
}
T _t;
QVector <U> _vectorU;
};

class ComplexStructure {
public:
ComplexStructure (int anInt, float aFloat): _anInt (anInt), _aFloat (aFloat) {
for (int i = 0; i < anInt; ++i) {
_aList.push_back (_aFloat+i*i);
}
}
int _anInt;
float _aFloat;
QList <int> _aList;
};

QDebug operator<<(QDebug dbg, const ComplexStructure& c) {
dbg.nospace() << QString ("ComplexStructure (_anInt = %1, _aFloat=%2, _aSet=").arg (c._anInt).arg (c._aFloat) << c._aList << ")";
return dbg.space();
}

int main(int argc, char **argv) {
QVector <int> intVector (6, 1); // be able to see the ints

MyClass <QString, float> myClass ("a string", 3.5f, 5);
qDebug () << myClass._t;
qDebug () << myClass._vectorU;

// it prints "a string"
// QVector(3.5, 3.5, 3.5, 3.5, 3.5) in totalview QVector should display as std::vector

ComplexStructure complexStructure1 (6, 2);
qDebug () << complexStructure1;
ComplexStructure complexStructure2 (3, 3);
qDebug () << complexStructure2;

QMap <int, ComplexStructure*> aMap;
aMap[0] = &complexStructure1;
aMap[1] = &complexStructure2;

qDebug () << aMap;


return 0;
}

In this program, apart from the QString we can't access any internal structure of objects. A click on the internal variables of the vector prints something like: Member '' no longer exists in type 'QVector<float>' ....
The output of this program is:

"a string"
QVector(3.5, 3.5, 3.5, 3.5, 3.5)
"ComplexStructure (_anInt = 6, _aFloat=2, _aSet="(2, 3, 6, 11, 18, 27) )
"ComplexStructure (_anInt = 3, _aFloat=3, _aSet="(3, 4, 7) )
QMap((0, 0x7fffc1f53100)(1, 0x7fffc1f53110))

We can note in the case of the map that we can't see directly the content of the map. We would have to write some additional code to iterate over the map and deference the pointers. I tried to check your APIs to display non standard type but it would be too involving for me to write something and I guess that my management wouldn't appreciate that much that I work on this. Do you have plans to add better support for QT?

Thanks

Yann