简体   繁体   中英

Detailed information from QObject::connect

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.

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.

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()).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM