PDA

View Full Version : howto debug connection of signals and slots?



jh
13th February 2006, 22:19
hi,

in older versions Qt gave a warning on the console when a signal
or slot could not be connected, e.g. if there was not such a slot.
in qt4 if you do a mistake just nothing happens. how can i get
an error message a warning or whatever when a signal could
not be connected to a slot?

best regards,
jh

jacek
13th February 2006, 22:48
On windows you must add "CONFIG += console" to your .pro file.

orb9
14th February 2006, 00:32
I'm experiencing the same problem under Qt4/Linux.

No warnings about signal/slot errors. Checked the docs of qmake for some flag to do the magic but i had no luck with warn_on which is only for the compiler and not for runtime warnings.
Maybe these are just enabled in a debug build, but i don't have the Qt4 debug version build so I cannnot check this.

Any ideas?

wysota
14th February 2006, 00:35
Are you building a debug version of your app? (CONFIG+=debug)

jh
14th February 2006, 20:25
i'm not using qmake. what compiler/linker (g++) flags do i have to set?

jh

wysota
14th February 2006, 20:50
Hmm... These are what I get while compiling an empty file with debug turned on.

g++ -c -pipe -Wall -W -g -DQT_SHARED -DQT_NO_DEBUG -DQT_THREAD_SUPPORT

orb9
15th February 2006, 00:43
Watch the source, Luke!

QObject.cpp has to tell the following:


#ifndef QT_NO_DEBUG
if (!QMetaObject::checkConnectArgs(signal, method)) {
qWarning("Object::connect: Incompatible sender/receiver arguments"
"\n\t%s::%s --> %s::%s",
sender->metaObject()->className(), signal,
receiver->metaObject()->className(), method);
return false;
}
#endif


So you only get those slot warnings in debug builds which have the QT_NO_DEBUG compiler flag set. :eek:
In Qt3 it was quite handy to get those warnings in optimized builds too.

jacek
15th February 2006, 00:49
So you only get those slot warnings in debug builds which have the QT_NO_DEBUG compiler flag set. :eek:
Isn't there "#ifndef"? I would say that you will get the warning if you compile your application with QT_NO_DEBUG unset.

orb9
16th February 2006, 20:41
I would say that you will get the warning if you compile your application with QT_NO_DEBUG unset.
You are right - i would get the warnings back.
But unsetting QT_NO_DEBUG would also activate all other debug features, effectively giving me a debug build.
In Qt3 i also got those warnings for an optimized build.

Chicken Blood Machine
16th February 2006, 22:03
You are right - i would get the warnings back.
But unsetting QT_NO_DEBUG would also activate all other debug features, effectively giving me a debug build.
In Qt3 i also got those warnings for an optimized build.
Setting QT_DEBUG should achieve that.

jamadagni
24th February 2006, 09:55
Are you building a debug version of your app? (CONFIG+=debug)
I get the following error upon including CONFIG+= debug into the pro file:

$ make
g++ -o jd-date main.o -L/usr/lib -lQtGui_debug -lQtCore_debug -lpthread
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../../i586-suse-linux/bin/ld: cannot find -lQtGui_debug
collect2: ld returned 1 exit status
make: *** [jd-date] Error 1

wysota
24th February 2006, 10:30
You have only release mode libraries from Qt. You need to reconfigure and recompile Qt with an appropriate option (see configure -help for details) or install a binary package with debug libraries appropriate for your system.