The memory management is such that the memory will be deleted if there are no references to it from R or a Qt object. The &quot;Qt object&quot; part depends on the type of object being considered for deletion. In this case, a QLayout is a QObject, so it is owned by its parent. The parent is the widget (unless this is a sub-layout). So to delete the layout, you need to set NULL for the layout of the widget and rm() any references from R. And then run gc(). Let me know if that works. <br>
<br>Changing the layout of a widget is a bit strange though -- what are you trying to do?<br><br><div class="gmail_quote">On Mon, Apr 11, 2011 at 9:57 PM, Tengfei Yin <span dir="ltr">&lt;<a href="mailto:yintengfei@gmail.com">yintengfei@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi<div><br></div><div>I hope to delete and create a new layout without destroying a widget, based on Qt documentation, </div>
<div><br></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<span style="color: rgb(54, 53, 52); font-family: Verdana; line-height: 20px;"><font size="4">If there already is a layout manager installed on this widget, <a href="http://doc.qt.nokia.com/4.7/qwidget.html" style="color: rgb(0, 115, 47); text-decoration: none;" target="_blank">QWidget</a> won&#39;t let you install another. You must first delete the existing layout manager (returned by <a href="http://doc.qt.nokia.com/4.7/qwidget.html#layout" style="color: rgb(0, 115, 47); text-decoration: none;" target="_blank">layout</a>()) before you can call setLayout() with the new layout.</font></span></blockquote>


<div><br></div><div><span style="color: rgb(54, 53, 52); font-family: Verdana; font-size: 13px; line-height: 20px;"></span>to add a layout to an existing widgets,  I find something like</div><div>

<br></div><div><span style="font-family: &#39;Times New Roman&#39;; font-size: medium;"><pre>void myWidget::makeLayout()
{
  // Delete old layout (if any)
  delete layout();  // This is QWidget::layout()

  // Perhaps you have to remove, add, hide or show some childwidgets.

 .....
  ...
}</pre></span></div><div>So how to do that in R, I cannot find something like close() or delete() for QWidget$layout(). </div><div><br></div><div>Thanks</div><div><br></div><div>Tengfei</div><div><br clear="all"><br>-- <br>


Tengfei Yin<br>MCDB PhD student <br>1620 Howe Hall, 2274,<br>Iowa State University<br>Ames, IA,50011-2274<br>Homepage: <a href="http://www.tengfei.name" target="_blank">www.tengfei.name</a><br><div><br></div><br>
</div>
<br>_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
<br></blockquote></div><br>