tags:

views:

138

answers:

3

Is there a way to get a detailed failure information from QObjet::connect in case of its failure ?

Returned boolean value doesn't give any information about reason of failure.

I wish exception were so widely used in C++ as they are in Java.

A: 

If I remember correctly, the debug build will output a more detailled error message to the debugger. Helped me more than once to fix a bug.

OregonGhost
Do I need to build QT in debug mode myself under Windows ?
lbownik
Hmm, no, not if you download the binaries from Trolltech :)Just be sure to reference the debug libraries (e.g. QtGuid4.dll instead of QtGui4.dll) in your debug build.
OregonGhost
+1  A: 

As OregonGhost said, you'll have to check the output during runtime to see more informations about a connect failure.

To make sure the information displayed by Qt during runtime is helpful, ensure your give your QObjects a distinct name (QObject::setObjectName()).

Jérôme
+2  A: 

In addition to the other answers, you can install your own function that is called for Qt debug, warning, or fatal messages. Our program has this, and for debug builds, we pop up a dialog detailing the problem if it is a warning or fatal message. I believe most of the missed slot connections appear as warning messages, which details what it is trying to connect. Many times, I look at what it shows and it is a bit different than what I thought I was connecting.

Caleb Huitt - cjhuitt