Results 1 to 7 of 7

Thread: Avoiding leaks with layout managers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Avoiding leaks with layout managers

    Quote Originally Posted by jpn View Post
    The layout manager becomes a child of the widget it is installed on so you don't need to delete it by hand.
    How about buttons, textfields, checkboxes, etc?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Avoiding leaks with layout managers

    Quote Originally Posted by invictus View Post
    How about buttons, textfields, checkboxes, etc?
    The layout manager handles reparenting of them. All widgets added to a layout become also children of the widget the layout is installed on.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Avoiding leaks with layout managers

    So basicly I never have to delete any component that is displayed on another widget?

    Will there be problems if I do delete something that is a child of a widget?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Avoiding leaks with layout managers

    QObjects delete their children automatically and inform their parent when they get deleted. In addition, all relevant signal slot connections are also cleaned up. You are free to delete QObjects when you feel so with the exception that the sender of a signal must not be deleted in a slot.

    Further reading: Object Trees and Object Ownership, notice QObject::dumpObjectTree() which is handy for examining object trees.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2007
    Posts
    61
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Avoiding leaks with layout managers

    Thanks for the info!

    I assume the QSocket and such need to be deleted though



    Who needs Java garbage-collector anyway

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  2. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 22:54
  3. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 07:16
  4. Layout Managers???
    By jayw710 in forum Qt Programming
    Replies: 7
    Last Post: 18th February 2006, 03:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.