Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Debug cause of `QObject::connect: invalid null parameter`
Forum Update on Monday, May 27th 2025

Debug cause of `QObject::connect: invalid null parameter`

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 20.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    skebanga
    wrote on 13 Mar 2018, 21:39 last edited by
    #1

    I am getting an error message on stderr

    QObject::connect: invalid null parameter
    

    I do not know where in my code this is coming from.

    Is there a way to work out which connection is invalid?

    For example, I'd like to configure Qt to abort or throw an exception etc when I attempt to connect with a null parameter.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Mar 2018, 21:43 last edited by
      #2

      Hi,

      Then you should assert the objects you are using in your connection calls.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        skebanga
        wrote on 13 Mar 2018, 21:45 last edited by
        #3

        Absolutely agree.

        However, there are thousands of QObject::connect calls throughout my codebase.

        I do not know where the regression is coming from, and so am looking for help from the framework.

        The fact Qt will emit an error message to stderr means it is checking the objects itself - so is there a way to get Qt to fail hard and fail early when given an invalid object?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 13 Mar 2018, 21:49 last edited by
          #4

          QT_FATAL_WARNINGS to the rescue ! Define this environment variable and your application will crash when a qWarning is used. You can then get the stack trace.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 13 Mar 2018, 21:54
          5
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 13 Mar 2018, 21:50 last edited by
            #5

            Or you could install a message handler and break/crash/log/whatever when the message happens.

            S 1 Reply Last reply 13 Mar 2018, 21:54
            2
            • S SGaist
              13 Mar 2018, 21:49

              QT_FATAL_WARNINGS to the rescue ! Define this environment variable and your application will crash when a qWarning is used. You can then get the stack trace.

              S Offline
              S Offline
              skebanga
              wrote on 13 Mar 2018, 21:54 last edited by
              #6

              @SGaist awesome, thank you!

              1 Reply Last reply
              0
              • C Chris Kawa
                13 Mar 2018, 21:50

                Or you could install a message handler and break/crash/log/whatever when the message happens.

                S Offline
                S Offline
                skebanga
                wrote on 13 Mar 2018, 21:54 last edited by
                #7

                @Chris-Kawa equally awesome, thank you too!

                1 Reply Last reply
                0

                1/7

                13 Mar 2018, 21:39

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved