[RQt-devel] How to delete a layout in an existing widget?

Michael Lawrence lawrence.michael at gene.com
Tue Apr 12 07:15:13 CEST 2011


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 "Qt object" 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.

Changing the layout of a widget is a bit strange though -- what are you
trying to do?

On Mon, Apr 11, 2011 at 9:57 PM, Tengfei Yin <yintengfei at gmail.com> wrote:

> Hi
>
> I hope to delete and create a new layout without destroying a widget, based
> on Qt documentation,
>
> If there already is a layout manager installed on this widget, QWidget<http://doc.qt.nokia.com/4.7/qwidget.html> won't
>> let you install another. You must first delete the existing layout manager
>> (returned by layout <http://doc.qt.nokia.com/4.7/qwidget.html#layout>())
>> before you can call setLayout() with the new layout.
>
>
> to add a layout to an existing widgets,  I find something like
>
> 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.
>
>  .....
>   ...
> }
>
> So how to do that in R, I cannot find something like close() or delete()
> for QWidget$layout().
>
> Thanks
>
> Tengfei
>
>
> --
> Tengfei Yin
> MCDB PhD student
> 1620 Howe Hall, 2274,
> Iowa State University
> Ames, IA,50011-2274
> Homepage: www.tengfei.name
>
>
>
> _______________________________________________
> Qtinterfaces-devel mailing list
> Qtinterfaces-devel at lists.r-forge.r-project.org
>
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/qtinterfaces-devel/attachments/20110411/3c7ded5b/attachment.htm>


More information about the Qtinterfaces-devel mailing list