我想用dumpObjectInfo函数打印对象信息的转储,但是什么也没打印。

以下是使用Qt的C++程序:

$ cat main1.cpp
#include <QObject>
#include <QString>
#include <QDebug>
#include "a.h"

int main() {
    A a;
    B b;
    QObject::connect(&b, SIGNAL(sendText(QString)), &a, SLOT(printText(QString)));
    b.sendSignal();
    qDebug() << "print object dump";
    a.dumpObjectInfo();
    return 0;
}

有以下.pro文件(在CONFIG中设置了 Debug模式):
$ cat qt.pro
######################################################################
# Automatically generated by qmake (2.01a) Tue Aug 28 17:41:22 2012
######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
CONFIG += debug
HEADERS += a.h
SOURCES += main1.cpp

汇编:
$ qmake qt.pro && make clean && make
rm -f moc_a.cpp
rm -f main1.o moc_a.o
rm -f *~ core *.core
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main1.o main1.cpp
/usr/bin/moc-qt4 -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. a.h -o moc_a.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o moc_a.o moc_a.cpp
g++  -o qt main1.o moc_a.o    -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread
{ test -n "" && DESTDIR="" || DESTDIR=.; } && test $(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 'qt' && test -f qt.gdb-index && objcopy --add-section '.gdb_index=qt.gdb-index' --set-section-flags '.gdb_index=readonly' 'qt' 'qt' && rm -f qt.gdb-index || true

运行程序:
$ ./qt
Signal text!

print object dump
$

在.pro文件中设置了 Debug模式后,dumpObjectInfo不会输出任何内容。如何使函数dumpObjectInfo打印对象信息?

最佳答案

如果尚未在 Debug模式下编译Qt库本身,这是可以预期的。 doc说:



为了使此工作有效,您可以从源代码自动编译Qt,而不是(或除此以外)使用预编译的软件包。

08-06 15:52