Results 1 to 2 of 2

Thread: Allocation of object within a function with pointer local on stack

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    518
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Allocation of object within a function with pointer local on stack

    Hi, the parent widget will delete its children, so PA will delete all the new A objects, but only when PA itself gets deleted. So while PA exists you will accumulate AType objects which you cannot access because you did not store a pointer (you could get a pointer by using methods like QObject::findChild, but I try to avoid that if I can).

    It would be nicer if you would clean unused AType objects, or (probably better because it avoids the new allocations) you can create it once on the first call, then re-use the AType object from the first call and only use show() and hide().

    Ginsengelf

  2. The following user says thank you to Ginsengelf for this useful post:

    montanaviking (3rd November 2020)

Similar Threads

  1. Correctly destruction of child objects inside stack object
    By papercut87 in forum Qt Programming
    Replies: 4
    Last Post: 12th August 2016, 17:36
  2. object allocation question
    By nuliknol in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2015, 17:15
  3. How to call a function in the mother object from a child object?
    By Momergil in forum General Programming
    Replies: 4
    Last Post: 18th December 2011, 15:49
  4. Stack object on top of one other
    By Markus_AC in forum Qt Programming
    Replies: 3
    Last Post: 23rd September 2011, 11:05
  5. Replies: 4
    Last Post: 10th May 2006, 22:37

Tags for this Thread

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.