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 happens automatically?
Forum Update on Monday, May 27th 2025

disconnect happens automatically?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 746 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
    Publicnamer
    wrote on 24 Sept 2021, 15:02 last edited by
    #1

    I have an object that needs to send signals to the GUI, so I connect it to a slot.
    However later I delete that object.
    I noticed I can always say when I'm done with the object:

    disconnect(myObject);
    

    However does this also happen automatically when its deallocator is called?

    J 1 Reply Last reply 24 Sept 2021, 15:05
    0
    • P Publicnamer
      24 Sept 2021, 15:02

      I have an object that needs to send signals to the GUI, so I connect it to a slot.
      However later I delete that object.
      I noticed I can always say when I'm done with the object:

      disconnect(myObject);
      

      However does this also happen automatically when its deallocator is called?

      J Offline
      J Offline
      JonB
      wrote on 24 Sept 2021, 15:05 last edited by JonB
      #2

      @Publicnamer
      Yep :)

      In general you don't need to worry about explicitly calling disconnect().

      1 Reply Last reply
      3
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 24 Sept 2021, 15:49 last edited by
        #3

        Properly explained in the documentation to QObject::disconnect(): 'A signal-slot connection is removed when either of the objects involved are destroyed.'

        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
        3

        1/3

        24 Sept 2021, 15:02

        • Login

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