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. isSignalConnected correct usage
Qt 6.11 is out! See what's new in the release blog

isSignalConnected correct usage

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.0k 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.
  • P Offline
    P Offline
    pixbyte
    wrote on last edited by
    #1

    to check if a signal is connected I use this code:

        if (!this->isSignalConnected(QMetaMethod::fromSignal(&QtVariantPropertyManager::propertyChanged))) {
    
            connect( sdkItemPropManager, SIGNAL( propertyChanged( QtProperty * ) ), this, SLOT( onUpdatePropertyValues() ) );
            connect( sdkEmuManager, SIGNAL( propertyChanged( QtProperty * ) ), this, SLOT( onUpdatePropertyValues() ) );
    
        }
    

    But I always got an Assert:

    ASSERT failure in QObject::isSignalConnected: "the parameter must be a signal member of the object", file \Users\qt\work\qt\qtbase\src\corelib\kernel\qobject.cpp, line 2539
    

    Is there an explanation that you can understand?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Why not simply use Qt::UniqueConnection?

      According to the documentation: "signal must be a signal member of this object, otherwise the behaviour is undefined."

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • P Offline
        P Offline
        pixbyte
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in isSignalConnected correct usage:

        Qt::UniqueConnection

        ok, this is really a good and helpfull tip. Thank you. But also Iam interrested why the initial code do not work.

        JonBJ 1 Reply Last reply
        0
        • P pixbyte

          @Christian-Ehrlicher said in isSignalConnected correct usage:

          Qt::UniqueConnection

          ok, this is really a good and helpfull tip. Thank you. But also Iam interrested why the initial code do not work.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @pixbyte
          I assume as the error message states.

          this->isSignalConnected(QMetaMethod::fromSignal(&QtVariantPropertyManager::propertyChanged)
          

          Is this of type QtVariantPropertyManager?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pixbyte
            wrote on last edited by
            #5

            No this is the target where the signal is connected on. I think here it is a mdi_child.

            JonBJ 1 Reply Last reply
            0
            • P pixbyte

              No this is the target where the signal is connected on. I think here it is a mdi_child.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @pixbyte
              Hence I presume the message

              "signal must be a signal member of this object, otherwise the behaviour is undefined."

              in answer to your

              But also Iam interrested why the initial code do not work.

              1 Reply Last reply
              2

              • Login

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