Results 1 to 12 of 12

Thread: howto debug connection of signals and slots?

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    84
    Thanks
    7
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default howto debug connection of signals and slots?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    On windows you must add "CONFIG += console" to your .pro file.

  3. #3
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: howto debug connection of signals and slots?

    Are you building a debug version of your app? (CONFIG+=debug)

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    84
    Thanks
    7
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    i'm not using qmake. what compiler/linker (g++) flags do i have to set?

    jh

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: howto debug connection of signals and slots?

    Hmm... These are what I get while compiling an empty file with debug turned on.
    Qt Code:
    1. g++ -c -pipe -Wall -W -g -DQT_SHARED -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    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.
    In Qt3 it was quite handy to get those warnings in optimized builds too.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    Quote Originally Posted by orb9
    So you only get those slot warnings in debug builds which have the QT_NO_DEBUG compiler flag set.
    Isn't there "#ifndef"? I would say that you will get the warning if you compile your application with QT_NO_DEBUG unset.

  9. #9
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    Quote Originally Posted by jacek
    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.

  10. #10
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: howto debug connection of signals and slots?

    Quote Originally Posted by orb9
    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.
    Save yourself some pain. Learn C++ before learning Qt.

  11. #11
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: howto debug connection of signals and slots?

    Quote Originally Posted by wysota
    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
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: howto debug connection of signals and slots?

    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.

  13. The following user says thank you to wysota for this useful post:

    jamadagni (24th February 2006)

Similar Threads

  1. Signals and Slots Problem
    By GenericProdigy in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2009, 09:06
  2. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  3. Problem with SpinBox signals and slots
    By ramstormrage in forum Newbie
    Replies: 4
    Last Post: 2nd May 2008, 01:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.