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. Qt Signal and slots across application and DLLs
QtWS25 Last Chance

Qt Signal and slots across application and DLLs

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 705 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
    PoonamGupta
    wrote on last edited by
    #1

    The child class is derived from the Parent class. The parent class is in DLL and Child class is derived from it which is in the application exe.
    Parent Class has m_classA and m_classB as a protected member pointer variable.

    I am doing following connection in my Child class by using above protected member pointer variable.
    connect(m_classA, &ClassA::sig_pointDataStarted, m_classB, &ClassB::slt_pointDataStarted);

    Now when I am trying to disconnect above connection in DLL then it's not working.

    bool disconnectOk = disconnect(m_classA, &ClassA::sig_pointDataStarted, m_classB, &ClassB::slt_pointDataStarted);

    disconnectOk is coming as false. i.e Qt is not able to find able connections in DLL.

    As per my understanding Signal and slots depends on the sender and receiver references/Pointer.

    Could anyone help me to understand why disconnect is not working in DLL when the connection has been done at application level?

    Thanks in advance.

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

      Did you check if the connect worked as expected?

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

      P 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Did you check if the connect worked as expected?

        P Offline
        P Offline
        PoonamGupta
        wrote on last edited by
        #3

        @christian-ehrlicher

        Yes I checked Connection is working as expected.

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

          QObject::connect() returns a QMetaObject::Connection which can be used to do disconnect later on: https://doc.qt.io/qt-5/qobject.html#disconnect-4
          Please check if it works with them. If not please try to provide a minimal example so we can maybe see what's going wrong. Do you properly export the two classes and do they both have the Q_OBJECT macro?

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

          P 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            QObject::connect() returns a QMetaObject::Connection which can be used to do disconnect later on: https://doc.qt.io/qt-5/qobject.html#disconnect-4
            Please check if it works with them. If not please try to provide a minimal example so we can maybe see what's going wrong. Do you properly export the two classes and do they both have the Q_OBJECT macro?

            P Offline
            P Offline
            PoonamGupta
            wrote on last edited by
            #5

            @christian-ehrlicher

            Sure, I will try to create a minimal example. Both classes have Q_OBJECT macro. So when I move both connection and disconnect command in DLL then everything works, but I am still confused why it's not working when we try to connect in Application-level and disconnect at DLL level.

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

              Me neither, I'm not aware of any problems with your approach.

              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
              0

              • Login

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