I found the code and copied it into simple little class (bellow) and it works that way But the QObject::DumpObjectTree() still does not work. I call it like this from main.
@
MainWindow mw;
DumpTree::dumpObjectTree(&mw);
mw.show();@
I changed the method declarations so instead of dumping “this' I pass in a pointer to what I want dumped. Otherwise the code is exactly how I copied it out of qobject.cpp file. This will work for now but it would be nice to get it fixed right, especially if other people are having the same problem. Any ideas how to troubleshoot this. Thanks
@#ifndef DUMPOBJECTTREE_H
#define DUMPOBJECTTREE_H
#include <QObject>
class DumpTree : public QObject {
Q_OBJECT
public:
static void dumpObjectTree( const QObject* ob) {
dumpRecursive(0, ob);
}
private:
static void dumpRecursive(int level, const QObject *object) {
#if defined(QT_DEBUG)
if (object) {
QByteArray buf;
buf.fill(' ', level / 2 * 8);
if (level % 2)
buf += " ";
QString name = object->objectName();
QString flags = QLatin1String("");
#if 0
if (qApp->focusWidget() == object)
flags += 'F';
if (object->isWidgetType()) {
QWidget * w = (QWidget ) object;
if (w->isVisible()) {
QString t("<%1,%2,%3,%4>");
flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height());
} else {
flags += 'I';
}
}
#endif
qDebug("%s%s::%s %s", (const char) buf, object->metaObject()->className(), name.toLocal8Bit().data(),
flags.toLatin1().data());
QObjectList children = object->children();
if (!children.isEmpty()) {
for (int i = 0; i < children.size(); ++i)
dumpRecursive(level + 1, children.at(i));
}
}
#else
Q_UNUSED(level)
Q_UNUSED(object)
#endif
}
};
#endif /* DUMPOBJECTTREE_H */
@