Important: Please read the Qt Code of Conduct -

DumpObjectTree not showing any output in netbeans Linux Kubuntu

  • I am trying to use the QObject::DumpObjectTree() method but it does not show any output. I am using netbeans IDE and the built in terminal shows anything I send to std::cout and std::cerr. I ran the compiled program from the terminal and it does not show anything there either. I tried DumpObjectTree with a simple project in Qt Creator with the same results. Is there some place I could see the code in the DumpObjectTree() method. There was a similar issue from several years back that was not resolved.

    I would really like to use that method so any help would be appreciated.


  • 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;

    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


    #include <QObject>

    class DumpTree : public QObject {


    static void dumpObjectTree( const QObject* ob) {
    dumpRecursive(0, ob);


    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';
    qDebug("%s%s::%s %s", (const char
    ) buf, object->metaObject()->className(), name.toLocal8Bit().data(),
    QObjectList children = object->children();
    if (!children.isEmpty()) {
    for (int i = 0; i < children.size(); ++i)
    dumpRecursive(level + 1,;


    #endif /* DUMPOBJECTTREE_H */

Log in to reply