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
Forum Updated to NodeBB v4.3 + New Features

Delete widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.9k 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 3 Jul 2019, 08:07 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.

    J 1 Reply Last reply 3 Jul 2019, 08:11
    0
    • M mahd96
      3 Jul 2019, 08:07

      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.

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 3 Jul 2019, 08:11 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 3 Jul 2019, 09:35
      1
      • M Offline
        M Offline
        mahd96
        wrote on 3 Jul 2019, 09:34 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • J JKSH
          3 Jul 2019, 08:11

          @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 3 Jul 2019, 09:35 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!

          J 1 Reply Last reply 3 Jul 2019, 10:23
          0
          • J JKSH
            3 Jul 2019, 08:11

            @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 3 Jul 2019, 09:38 last edited by
            #5

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

            J 1 Reply Last reply 3 Jul 2019, 11:39
            0
            • M mahd96
              3 Jul 2019, 09:35

              @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!

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 3 Jul 2019, 10:23 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
                3 Jul 2019, 09:38

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

                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 3 Jul 2019, 11:39 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

                1/7

                3 Jul 2019, 08:07

                • Login

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