Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QObject::dumpObjectTree() on ubuntu 9.10

Problem with QObject::dumpObjectTree() on ubuntu 9.10

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tokyoben
    wrote on last edited by
    #1

    Hello everybody!

    I'm somewhat of a novice to Qt and I'm trying to learn it using an Ubuntu 9.10 box. I've done a fair amount of google search and tried different things before posting this thread, so as not to bother people needlessly. However, after several hours of frustration, I could not get dumpObjectTree() to produce anything for a simple console app (even QDebug is not working). I've looked thru my Qt libs and I don't see anything with a dbg ending (or anything roughly similar that). Somewhere I found a post where there was a hint that there may be some limitations using Qtdebug libraries on Linux.

    Among the things I've tried:

    1. added CONFIG += debug to .pro file
    2. added CONFIG += release_and_debug to .pro file
    3. installed the libqt4-dbg using Synaptic

    Even when I used QtCreator on debug mode I could not get any response from dumpObjectTree().

    So it seems to me that there is either something basically wrong with my procedure (unlikely I think) or I'm not using the appropriate libraries.

    Could anybody give me a hint on how to go about this?

    Thanks!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      viswesr
      wrote on last edited by
      #2

      I use Ubuntu 10.04 and Qt 4.7.0 snapshot version compiled from source code, dumpObjectTree works well. eg:

      @int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      MainWindow w;
      w.setWindowFlags(Qt::WindowStaysOnTopHint);
      w.dumpObjectTree();
      w.show();

      return a.exec();
      

      }
      @

      output:
      @
      MainWindow::MainWindow
      QMainWindowLayout::_layout
      QRubberBand::qt_rubberband
      QMenuBar::menuBar
      QToolButton::qt_menubar_ext_button
      QToolBar::mainToolBar
      QToolBarLayout::
      QToolBarExtension::qt_toolbar_ext_button
      QAction::
      QWidget::centralWidget
      QStatusBar::statusBar
      QSizeGrip::
      QHBoxLayout::
      QVBoxLayout::
      QHBoxLayout::
      @

      1.If you are using Qt creator, use debug Build
      2.Try compiling Qt from source / use the Nokia released version instead of distribution version.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tokyoben
        wrote on last edited by
        #3

        Thanks for the reply.

        I've downloaded the latest Qt SDK using this link
        http://qt.nokia.com/downloads/sdk-linux-x11-32bit-cpp (http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2010.04.bin)

        I tried using the debug build and it didn't work!

        I also copied all the lib*.so.4.6.1.debug files from /usr/local/Trolltech/Qt-4.6.1/lib to my /usr/lib folder and renamed them *_debug.so and altered the Makefile to use only the now created libQtCore_debug.so library. It also didn't work!

        I tried to find the source code for the latest Qt SDK (or even the framework only) from the Nokia site, but I could only find pre-compiled binaries.

        Since the example that I'm tried to run is so simple (no GUI only console) I'm almost certain that I have a library compatibility problem OR I'm not using some requeired compiler/linker flags (unlikely).

        I'm almost giving up on getting dumpObjectTree and QDebug to run on my Ubuntu 9.10!

        Thanks for the attention!

        1 Reply Last reply
        0
        • V Offline
          V Offline
          viswesr
          wrote on last edited by
          #4

          Can you post the .pro and example .cpp files?

          Also try Qt 4.7.0 RC1 available here:
          "Qt prerelease downloads":http://qt.nokia.com/developer/qt-qtcreator-prerelease
          "Qt 4.7.0 RC1 Src":http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.0-rc1.tar.gz

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tokyoben
            wrote on last edited by
            #5

            The example is a simple one based on the web available notes by Ezust, really basic stuff!
            1)Below are the .pro and cpp/h files I used with Eclipse:

            1.a)
            ######################################################################

            Automatically generated by qmake (2.01a) Tue Sep 14 15:39:04 2010

            ######################################################################

            TEMPLATE = app
            TARGET =
            DEPENDPATH += .
            INCLUDEPATH += .
            LIBS = -L/usr/local/Trolltech/Qt-4.6.1/lib
            #CONFIG += debug_and_release
            CONFIG += debug

            Input

            HEADERS += Personna.h
            SOURCES += main.cpp Personna.cpp

            1.b)main.cpp

            /*

            • main.cpp
            • Created on: Sep 14, 2010
            •  Author: ben
              

            */

            #include <QTextStream>
            #include <QDebug>
            #include "Personna.h"

            static QTextStream cout(stdout, QIODevice::WriteOnly);

            void showTree(QObject* theparent){
            foreach(QObject* const person, theparent->children()){
            if(person->parent()==theparent){
            cout << "Member: "<<person->objectName()<<" - Parent:"<<theparent->objectName()<<endl;
            showTree(person);
            }
            }
            }
            int main(int , char**) {
            cout << "First we create a bunch of objects." << endl;
            Personna bunch(0, "A Stack Object");
            /* other objects are created on the heap */
            Personna *mike = new Personna(&bunch, "Mike");
            Personna *carol = new Personna(&bunch, "Carol");
            new Personna(mike, "Greg");
            new Personna(mike, "Peter");
            new Personna(mike, "Bobby");
            new Personna(carol, "Marcia");
            new Personna(carol, "Jan");
            new Personna(carol, "Cindy");
            Personna *alice=new Personna(0, "Alice");
            new Personna(alice, "King");
            new Personna(alice, "Queen");

            cout << "\nDisplay the list using QObject::dumpObjectTree()"
                      << endl;
            bunch.dumpObjectTree();
            QDebug(&QString(" QDebug() called!"));
            
            showTree(&bunch);
            showTree(alice);
            cout << "\nProgram finished - destroy all objects." << endl;
            return 0;
            

            }

            1.c) Personna.cpp
            /*

            • Personna.cpp
            • Created on: Sep 14, 2010
            •  Author: ben
              

            */

            #include "Personna.h"
            #include <QTextStream>

            static QTextStream cout(stdout, QIODevice::WriteOnly);
            Personna::Personna(QObject* parent, QString name)
            : QObject(parent) {
            setObjectName(name);
            cout << QString("Constructing Person: %1").arg(name) << endl;
            }
            Personna::~Personna() {
            cout << QString("Destroying Person: %1").arg(objectName()) <<
            endl;
            }
            1.d) Personna.h
            /*

            • Personna.h
            • Created on: Sep 14, 2010
            •  Author: ben
              

            */

            #ifndef PERSONNA_H_
            #define PERSONNA_H_

            #include <QObject>
            #include <QString>

            class Personna : public QObject{
            public:
            Personna(QObject* parent, QString name);
            virtual ~Personna();
            };

            #endif /* PERSONNA_H_ */
            2)Below is the .pro file I used with QtCreator(latest linux binary release) (The cpp/h files are the same as above):
            #-------------------------------------------------

            Project created by QtCreator 2010-09-15T00:42:26

            #-------------------------------------------------

            QT += core

            QT -= gui

            TARGET = qobj
            CONFIG += console
            CONFIG -= app_bundle
            CONFIG += debug

            TEMPLATE = app

            SOURCES += main.cpp
            personna.cpp

            HEADERS +=
            personna.h

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              Would you mind adding some code tags? Your comment is hardly readable right now.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tokyoben
                wrote on last edited by
                #7

                Trying again!
                The example is a simple one based on the web available notes by Ezust (I changed slightly the code), really basic stuff!
                1)Below are the .pro and cpp/h files I used with Eclipse:

                1.a)
                @
                ######################################################################

                1. Automatically generated by qmake (2.01a) Tue Sep 14 15:39:04 2010

                  ######################################################################

                  TEMPLATE = app

                  TARGET =

                  DEPENDPATH += .

                  INCLUDEPATH += .

                  LIBS = -L/usr/local/Trolltech/Qt-4.6.1/lib

                  #CONFIG += debug_and_release

                  CONFIG += debug

                Input

                  HEADERS += Personna.h
                
                
                  SOURCES += main.cpp Personna.cpp
                

                @
                1.b)main.cpp
                @

                  /*
                  * main.cpp * * Created on: Sep 14, 2010 * Author: ben */
                
                
                
                  #include “Personna.h”
                
                
                
                  static QTextStream cout(stdout, QIODevice::WriteOnly);
                

                void showTree(QObject* theparent){
                foreach(QObject* const person, theparent->children()){
                cout << "Member: "<< person->objectName()<<" - Parent:"<<theparent->objectName()<<endl;
                showTree(person);
                }
                }

                  int main(int , char**) { 
                

                cout << “First we create a bunch of objects.” << endl;

                Personna bunch(0, “A Stack Object”);

                /* other objects are created on the heap */

                Personna *mike = new Personna(&bunch, “Mike”);

                Personna *carol = new Personna(&bunch, “Carol”);

                new Personna(mike, “Greg”);

                new Personna(mike, “Peter”);

                new Personna(mike, “Bobby”);

                new Personna(carol, “Marcia”);

                new Personna(carol, “Jan”);

                new Personna(carol, “Cindy”);

                Personna *alice=new Personna(0, “Alice”);

                new Personna(alice, “King”);

                new Personna(alice, “Queen”);

                cout << ”\nDisplay the list using QObject::dumpObjectTree()” << endl;

                bunch.dumpObjectTree();

                QDebug(&QString(” QDebug() called!”));

                showTree(&bunch);

                showTree(alice);

                cout << ”\nProgram finished – destroy all objects.” << endl;
                //alice leaks on purpose
                return 0;

                  }
                

                @

                  1.c) Personna.cpp
                

                @

                  /*
                  * Personna.cpp * * Created on: Sep 14, 2010 * Author: ben */
                
                  #include “Personna.h”
                
                
                  static QTextStream cout(stdout, QIODevice::WriteOnly);
                
                
                  Personna::Personna(QObject* parent, QString name)
                  : QObject(parent) { 
                
                            setObjectName(name); 
                
                            cout << QString(“Constructing Person: %1”).arg(name) << endl;
                
                
                  }
                
                
                  Personna::~Personna() { 
                
                             cout << QString(“Destroying Person: %1”).arg(objectName()) << endl;
                
                
                  }
                

                @
                1.d) Personna.h
                @

                  /* * Personna.h * * Created on: Sep 14, 2010 * Author: ben */
                
                  #ifndef PERSONNA_H_
                
                  #define PERSONNA_H_
                
                
                
                  class Personna : public QObject{
                
                
                  public:
                
                
                  Personna(QObject* parent, QString name); 
                

                virtual ~Personna();

                  };
                
                  #endif /* PERSONNA_H_ */
                

                @
                2)Below is the .pro file I used with QtCreator(latest linux binary release) (The cpp/h files are the same as above):

                @

                  #————————————————————————-
                
                  #Project created by QtCreator 2010-09-15T00:42:26
                
                  #
                
                  #————————————————————————-
                
                  QT += core
                
                  QT -= gui
                
                  TARGET = qobj
                  CONFIG += console
                  CONFIG -= app_bundle
                  CONFIG += debug
                
                  TEMPLATE = app
                
                  SOURCES += main.cpp \
                  personna.cpp
                
                  HEADERS += \
                  personna.h 
                

                @

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tokyoben
                  wrote on last edited by
                  #8

                  This is the output I get:

                  @
                  First we create a bunch of objects.
                  Constructing Person: A Stack Object
                  Constructing Person: Mike
                  Constructing Person: Carol
                  Constructing Person: Greg
                  Constructing Person: Peter
                  Constructing Person: Bobby
                  Constructing Person: Marcia
                  Constructing Person: Jan
                  Constructing Person: Cindy
                  Constructing Person: Alice
                  Constructing Person: King
                  Constructing Person: Queen

                  Display the list using QObject::dumpObjectTree()
                  Member: Mike - Parent:A Stack Object
                  Member: Greg - Parent:Mike
                  Member: Peter - Parent:Mike
                  Member: Bobby - Parent:Mike
                  Member: Carol - Parent:A Stack Object
                  Member: Marcia - Parent:Carol
                  Member: Jan - Parent:Carol
                  Member: Cindy - Parent:Carol
                  Member: King - Parent:Alice
                  Member: Queen - Parent:Alice

                  Program finished - destroy all objects.
                  Destroying Person: A Stack Object
                  Destroying Person: Mike
                  Destroying Person: Greg
                  Destroying Person: Peter
                  Destroying Person: Bobby
                  Destroying Person: Carol
                  Destroying Person: Marcia
                  Destroying Person: Jan
                  Destroying Person: Cindy

                  @

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    viswesr
                    wrote on last edited by
                    #9

                    I get the following correct output:
                    @
                    First we create a bunch of objects.
                    Constructing Person: A Stack Object
                    Constructing Person: Mike
                    Constructing Person: Carol
                    Constructing Person: Greg
                    Constructing Person: Peter
                    Constructing Person: Bobby
                    Constructing Person: Marcia
                    Constructing Person: Jan
                    Constructing Person: Cindy
                    Constructing Person: Alice
                    Constructing Person: King
                    Constructing Person: Queen

                    Display the list using QObject::dumpObjectTree()
                    Member: Mike - Parent:A Stack Object
                    Member: Greg - Parent:Mike
                    Member: Peter - Parent:Mike
                    Member: Bobby - Parent:Mike
                    Member: Carol - Parent:A Stack Object
                    Member: Marcia - Parent:Carol
                    Member: Jan - Parent:Carol
                    Member: Cindy - Parent:Carol
                    Member: King - Parent:Alice
                    Member: Queen - Parent:Alice

                    Program finished – destroy all objects.
                    Destroying Person: A Stack Object
                    Destroying Person: Mike
                    Destroying Person: Greg
                    Destroying Person: Peter
                    Destroying Person: Bobby
                    Destroying Person: Carol
                    Destroying Person: Marcia
                    Destroying Person: Jan
                    Destroying Person: Cindy
                    QObject::A Stack Object
                    QObject::Mike
                    QObject::Greg
                    QObject::Peter
                    QObject::Bobby
                    QObject::Carol
                    QObject::Marcia
                    QObject::Jan
                    QObject::Cindy

                    @

                    Can you install 4.7.0 RC1 binary from the above links and try?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tokyoben
                      wrote on last edited by
                      #10

                      I tried with 4.7.0 RC1 binary and it didn't work. Below is my hand altered Makefile where I pointed everything to the newly installed Qt.

                      @
                      #############################################################################

                      Makefile for building: qobject

                      Generated by qmake (2.01a) (Qt 4.5.2) on: Thu Sep 16 08:14:35 2010

                      Project: qobject.pro

                      Template: app

                      Command: /usr/bin/qmake -unix -o Makefile qobject.pro

                      #############################################################################

                      ####### Compiler, tools and options

                      CC = gcc
                      CXX = g++
                      DEFINES = -DQT_DEBUG -DQT_CORE_LIB
                      CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
                      CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
                      INCPATH = -I/home/ben/Qt/qtsdk-2010.05/qt/mkspecs/linux-g++ -I. -I../../../Qt/qtsdk-2010.05/qt/include/QtCore -I/usr/include/qt4 -I. -I../../../Qt/qtsdk-2010.05/qt/include -I.
                      LINK = g++
                      LFLAGS = -Wl,-O1
                      LIBS = $(SUBLIBS) -L/home/ben/Qt/qtsdk-2010.05/lib -lQtCore -lpthread
                      AR = ar cqs
                      RANLIB =
                      QMAKE = /home/ben/Qt/qtsdk-2010.05/qt/bin/qmake
                      TAR = tar -cf
                      COMPRESS = gzip -9f
                      COPY = cp -f
                      SED = sed
                      COPY_FILE = $(COPY)
                      COPY_DIR = $(COPY) -r
                      INSTALL_FILE = install -m 644 -p
                      INSTALL_DIR = $(COPY_DIR)
                      INSTALL_PROGRAM = install -m 755 -p
                      DEL_FILE = rm -f
                      SYMLINK = ln -sf
                      DEL_DIR = rmdir
                      MOVE = mv -f
                      CHK_DIR_EXISTS= test -d
                      MKDIR = mkdir -p

                      ####### Output directory

                      OBJECTS_DIR = ./

                      ####### Files

                      SOURCES = main.cpp
                      Personna.cpp
                      OBJECTS = main.o
                      Personna.o
                      DIST = /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/g++.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/unix.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/linux.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/qconfig.pri
                      ......
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/lex.prf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/include_source_dir.prf
                      qobject.pro
                      QMAKE_TARGET = qobject
                      DESTDIR =
                      TARGET = qobject

                      ......

                      ####### Build rules

                      all: Makefile $(TARGET)

                      $(TARGET): $(OBJECTS)
                      $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

                      Makefile: qobject.pro /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/linux-g++/qmake.conf /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/g++.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/unix.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/linux.conf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/qconfig.pri
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/qt_functions.prf
                      ......
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/lex.prf
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/include_source_dir.prf
                      /home/ben/Qt/qtsdk-2010.05/qt/lib/libQtGui.prl
                      /home/ben/Qt/qtsdk-2010.05/qt/lib/libQtCore.prl
                      $(QMAKE) -unix -o Makefile qobject.pro
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/g++.conf:
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/unix.conf:
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/common/linux.conf:
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/qconfig.pri:
                      ......
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/lex.prf:
                      /home/ben/Qt/qtsdk-2010.05/qt/mkspecs/features/include_source_dir.prf:
                      /home/ben/Qt/qtsdk-2010.05/qt/lib/libQtGui.prl:
                      /home/ben/Qt/qtsdk-2010.05/qt/lib/libQtCore.prl:
                      qmake: FORCE
                      @$(QMAKE) -unix -o Makefile qobject.pro

                      dist:
                      @$(CHK_DIR_EXISTS) .tmp/qobject1.0.0 || $(MKDIR) .tmp/qobject1.0.0
                      $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qobject1.0.0/ && $(COPY_FILE) --parents Personna.h .tmp/qobject1.0.0/ && $(COPY_FILE) --parents main.cpp Personna.cpp .tmp/qobject1.0.0/ && (cd dirname .tmp/qobject1.0.0 && $(TAR) qobject1.0.0.tar qobject1.0.0 && $(COMPRESS) qobject1.0.0.tar) && $(MOVE) dirname .tmp/qobject1.0.0/qobject1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qobject1.0.0

                      clean:compiler_clean
                      -$(DEL_FILE) $(OBJECTS)
                      -$(DEL_FILE) *~ core *.core

                      ####### Sub-libraries

                      distclean: clean
                      -$(DEL_FILE) $(TARGET)
                      -$(DEL_FILE) Makefile

                      mocclean: compiler_moc_header_clean compiler_moc_source_clean

                      mocables: compiler_moc_header_make_all compiler_moc_source_make_all

                      compiler_moc_header_make_all:
                      compiler_moc_header_clean:
                      compiler_rcc_make_all:
                      compiler_rcc_clean:
                      compiler_image_collection_make_all: qmake_image_collection.cpp
                      compiler_image_collection_clean:
                      -$(DEL_FILE) qmake_image_collection.cpp
                      compiler_moc_source_make_all:
                      compiler_moc_source_clean:
                      compiler_uic_make_all:
                      compiler_uic_clean:
                      compiler_yacc_decl_make_all:
                      compiler_yacc_decl_clean:
                      compiler_yacc_impl_make_all:
                      compiler_yacc_impl_clean:
                      compiler_lex_make_all:
                      compiler_lex_clean:
                      compiler_clean:

                      ####### Compile

                      main.o: main.cpp Personna.h
                      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

                      Personna.o: Personna.cpp Personna.h
                      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o Personna.o Personna.cpp

                      ####### Install

                      install: FORCE

                      uninstall: FORCE

                      FORCE:

                      @

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved