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. Disconnect slot when deleting object

Disconnect slot when deleting object

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 3.7k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    Infinity
    wrote on last edited by
    #1

    Do I have to disconnect the slot of an object, when I delete the object with deleteLater() or will the slot be deleted when I call deleteLater() on the object?

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

      @Infinity said in Disconnect slot when deleting object:

      will the slot be deleted

      a slot is a function - this can not be deleted. What will be deleted is the connection between the signal and the slot.
      And yes this connection is deleted - anything else would be... hard to maintain.

      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
      4
      • Ashok KumarA Offline
        Ashok KumarA Offline
        Ashok Kumar
        wrote on last edited by Ashok Kumar
        #3

        No u need not disconnect the connect statement. No, the Slot will not be deleted when you delete the object since slot is nothing but a member function of the class. Just the object will be deleted and after the object is deleted the connection will be automatically disconnected.

        1 Reply Last reply
        2
        • S Offline
          S Offline
          shashikumar
          wrote on last edited by
          #4

          @Infinity may be you thinking in wrong way because slot is just a function and there is option like disconnect is only for connect statement ,so if you want to stop signal and slot communication then you may use this disconnect

          1 Reply Last reply
          0
          • I Infinity

            Do I have to disconnect the slot of an object, when I delete the object with deleteLater() or will the slot be deleted when I call deleteLater() on the object?

            A Offline
            A Offline
            anil_arise
            wrote on last edited by
            #5

            @Infinity this will help you . Disconnect . read carefully.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Infinity
              wrote on last edited by
              #6

              Thank you very much for your answers. Obviously my question was wrong. Of course I meant whether the slot will be disconnected and not deleted. Anyway I figured out from your answers that the slot will be disconnected when the Object is deleted with deleteLater(). Am I correct?

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

                @Infinity said in Disconnect slot when deleting object:

                when the Object is deleted with deleteLater(). Am I correct?

                I already answered this in the first post...

                And yes this connection is deleted

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

                I 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  @Infinity said in Disconnect slot when deleting object:

                  when the Object is deleted with deleteLater(). Am I correct?

                  I already answered this in the first post...

                  And yes this connection is deleted

                  I Offline
                  I Offline
                  Infinity
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher Yes. Thank you very much. Your answer was very helpful.

                  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