<div>Hi Michael, </div><div><br></div><div>Thanks, </div><div><br></div><div>I am not sure which object should be set to NULL.</div><div><br></div><div>&gt; trackWidget &lt;- Qt$QWidget()</div><div>&gt; trackLayout &lt;- Qt$QGridLayout()</div>

<div>&gt; trackWidget$setLayout(trackLayout)</div><div>NULL</div><div>&gt; trackWidget$layout()</div><div>QGridLayout instance</div><div>&gt; trackWidget$layout() &lt;- NULL</div><div>Error in trackWidget$layout() &lt;- NULL : </div>

<div>  invalid (NULL) left side of assignment</div><div><br></div><div>The layout() return a instance and it looks like it cannot be set to NULL.</div><div><br></div><div>My case may sounds weird, I changed view object to referecne class, say obj is a view object, obj$pars$seqname &lt;- &quot;chr3&quot;, will change the visualized chromosome and emit a signal to re-create multiple tracks for chr3 , I actually recreate the scene and view, but only keep the top widget which contains all tracks, so it looks like the windows is there, and only the view is updated, I am using a widget to embed two scenes in TracksView, this design is pretty much like USCSgenome browser, top scene shows a single chromosome, never be zoomed, and bottom scene contains multiple tracks, which zoom in/out at the same ratio. </div>

<div><br></div><div>To update this widget to visualize a new chromosome, I run the following command without creating a new Qwidget</div><div>.....</div><div><div> if(is.null(trackWidget)){</div><div>    trackWidget &lt;&lt;- Qt$QWidget()</div>

<div>  }</div></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>trackLayout &lt;- Qt$QGridLayout()</div><div>trackWidget$setLayout(trackLayout)</div></div><div>......</div><div><br></div>
This will give me a error saying the layout exists. it looks like it cannot be simply over created.<div>
<br></div><div>I just solved the problem by keeping the layout with QWidget, so I simply keep the top widget and layout at the same time, only create all scene and view and layers, now it works, I am still wondering how to delete that layout through, in case there is a use case in the future, such as update a layout design of one specific GUI without destroying it.</div>

<div><br></div><div>Thanks</div><div><br></div><div>Tengfei<br><div><div class="gmail_quote">On Tue, Apr 12, 2011 at 12:15 AM, Michael Lawrence <span dir="ltr">&lt;<a href="mailto:lawrence.michael@gene.com">lawrence.michael@gene.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">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"><div><div></div><div class="h5">On Mon, Apr 11, 2011 at 9:57 PM, Tengfei Yin <span dir="ltr">&lt;<a href="mailto:yintengfei@gmail.com" target="_blank">yintengfei@gmail.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div class="h5">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></div></div>_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org" target="_blank">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>
</blockquote></div><br><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></div>