Iterator problem

I have some difficulties iterating over a TList* object.
To be concise and precise, I have a TGTab containing n tabs.
I create them this way :

[code] fTab = new TGTab(this,5,5);
AddFrame(fTab, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX ,5,5,5,5));

fTab1 = fTab->AddTab("Analysis 1");  //here fTab1 is TGCompositeFrame type
an1 = new MainComposite(fTab1,500,500);
fTab1->AddFrame(an1,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY ,5,5,5,5));[/code]

And moreover, user can add as many tabs as he wants.

Once he’s done with tabs, he can save configuration. So I call the CreateXML() method on my main class and I have to run it in every tab opened, to save each configuration.
So, I want to iterate over the TGTab’s member : fList (class TList*) in order to call the CreateXML() method of each MainComposite object.

I did it this way :

TObjLink *lnk = fTab->GetList()->FirstLink(); while (lnk) { TGCompositeFrame *test = (TGCompositeFrame*) lnk->GetObject(); //here i need to get the "son" of TGCompositeFrame => MainComposite to call CreateXML() method lnk = lnk->Next(); }

Thanks in advance for help,



TGTab stores in its element list first a TGTabElement and then the TGCompositeFrame (or derived). So when looping over the list, you should skip the odd elements which are TGTabElements (you can check that by doing in you loop lnk->GetObject()->ClassName()).

Cheers, Fons.