Differences

This shows you the differences between two versions of the page.

Link to this comparison view

dev:layout_code [2013/07/21 14:59]
tedfelix [Let Qt 4 manage your parents] Memory Leak clarification
dev:layout_code [2013/07/21 15:00] (current)
tedfelix [Let Qt 4 manage your parents] this? addWidget()
Line 52: Line 52:
 </code> </code>
  
-All of this vBox begat frame begat QPushButton code can be removed for simplicity.  (QLayout::addItem() which is eventually called by this will take ownership of the widget.  So there is no danger of memory leaks.)  It is rarely necessary or beneficial to supply all these optional parent parameters.  This has many practical advantages, and has been greatly helpful to me in resolving broken layouts during this restructuring work.  If an existing layout ain't broke, there is little point in fixing it, but please do not write code like this in new layouts.  The example above will work perfectly fine when reduced to:+All of this vBox begat frame begat QPushButton code can be removed for simplicity.  (QLayout::addItem() which is eventually called by addWidget() will take ownership of the widget.  So there is no danger of memory leaks.)  It is rarely necessary or beneficial to supply all these optional parent parameters.  This has many practical advantages, and has been greatly helpful to me in resolving broken layouts during this restructuring work.  If an existing layout ain't broke, there is little point in fixing it, but please do not write code like this in new layouts.  The example above will work perfectly fine when reduced to:
  
 <code c++> <code c++>
 
 
dev/layout_code.1374411599.txt.gz · Last modified: 2013/07/21 14:59 by tedfelix
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki