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

Delete widget

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

    what happens to child widgets when the parent is deleted?
    no deconstructor is implemented.
    i have a crash in deleting a parent widget and i guess its because of some thing i didn't consider with children.

    JKSHJ 1 Reply Last reply
    0
    • M mahd96

      what happens to child widgets when the parent is deleted?
      no deconstructor is implemented.
      i have a crash in deleting a parent widget and i guess its because of some thing i didn't consider with children.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @mahd96 said in Delete widget:

      what happens to child widgets when the parent is deleted?

      The children are deleted too: https://doc.qt.io/qt-5/objecttrees.html

      i have a crash in deleting a parent widget and i guess its because of some thing i didn't consider with children.

      Try using deleteLater() instead of delete.

      Also, use a debugger and look at the stack trace when it crashes.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      M 2 Replies Last reply
      1
      • M Offline
        M Offline
        mahd96
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • JKSHJ JKSH

          @mahd96 said in Delete widget:

          what happens to child widgets when the parent is deleted?

          The children are deleted too: https://doc.qt.io/qt-5/objecttrees.html

          i have a crash in deleting a parent widget and i guess its because of some thing i didn't consider with children.

          Try using deleteLater() instead of delete.

          Also, use a debugger and look at the stack trace when it crashes.

          M Offline
          M Offline
          mahd96
          wrote on last edited by
          #4

          @JKSH it's not working. there is some point that i got to.
          for child that has pointer-like defenition(Qwidget *widget=new ...!) must use "this" keyword for initialzing them ( using setparent after creating object cause crash!)
          child that are not pointer like must be added to a layout.(again setparent will cause crash!)

          these behavior seems odd to me!

          jsulmJ 1 Reply Last reply
          0
          • JKSHJ JKSH

            @mahd96 said in Delete widget:

            what happens to child widgets when the parent is deleted?

            The children are deleted too: https://doc.qt.io/qt-5/objecttrees.html

            i have a crash in deleting a parent widget and i guess its because of some thing i didn't consider with children.

            Try using deleteLater() instead of delete.

            Also, use a debugger and look at the stack trace when it crashes.

            M Offline
            M Offline
            mahd96
            wrote on last edited by
            #5

            @JKSH i think theres issue with Construction/Destruction Order of QObjects.

            JKSHJ 1 Reply Last reply
            0
            • M mahd96

              @JKSH it's not working. there is some point that i got to.
              for child that has pointer-like defenition(Qwidget *widget=new ...!) must use "this" keyword for initialzing them ( using setparent after creating object cause crash!)
              child that are not pointer like must be added to a layout.(again setparent will cause crash!)

              these behavior seems odd to me!

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mahd96 said in Delete widget:

              for child that has pointer-like defenition(Qwidget *widget=new ...!) must use "this" keyword for initialzing them ( using setparent after creating object cause crash!)
              child that are not pointer like must be added to a layout.(again setparent will cause crash!)

              I don't really understand what you're trying to say. Can you show your code? How you're setting parent and how you're deleting?

              "i think theres issue with Construction/Destruction Order of QObjects" - I would first check my own code before saying that there is something wrong in the framework (which can, of course, be the case!).

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • M mahd96

                @JKSH i think theres issue with Construction/Destruction Order of QObjects.

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                @mahd96 said in Delete widget:

                @JKSH i think theres issue with Construction/Destruction Order of QObjects.

                Read the link I gave you: https://doc.qt.io/qt-5/objecttrees.html

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                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