Hi,

so far I understood objects derived from WObject are automatically deleted 
once their parent is deleted (similar to Qt QObjects), e.g.
new WLabel(parent)
is automatically deleted once parent is deleted.

When only using
new WLabel()
it has to be deleted manually.

I recognized that when using (nested) layouts at least within a 
WContainerWidget I have to create my WObjects without making it a child of 
the parent WContainerWidget, else I get a warning like
Warning: WContainerWidget: ignoring twice addWidget!

Simplified ctor:

SampleClass::SampleClass(...) : WContainerWidget(...)
{
        WVBoxLayout* vLayout = new VBoxLayout(this);
        WGridLayout* gridLayout = new WGridLayout();
        WLabel* foobar = new WLabel();
        
        vLayout->addItem(gridLayout);
        gridLayout->addWidget(foobar, 0, 0);
}

This works fine but I'm unsure whether I have to delete foobar manually.

If I specify 'this' (derived from WContainerWidget) to the WLabel ctor I get 
the above warning message.

Looking at the sourcecode it seems that WLayout::addWidget(widget) calls 
WContainerWidget::addWidget(widget) which would make widget a child of the 
WContainerWidget again and therefore it has not to be deleted manually.

I just want to be sure whether WObjects added to a WLayout become part of 
the object tree and are automatically deleted.

Also I'm unsure about the WLayouts itself as they don't derive from 
WObject - what's about them in this context?

Regards
Peter

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to