Embedding a TCanvas inside a TGTab

I’m writing a small GUI and I’d like to have a set of TCanvas’s which I can tab between. So I’d like a TGTab, where each tab has a frame with a TCanvas inside it.

The N=1 solution was just to use a TRootEmbeddedCanvas.

For N>1, I need to put the canvas inside the TGTab somehow.

I’ve tried the most intuitive thing:

(inside my TGMainFrame constructor):

///////////

for (int i=0;i<Ntabs;i++)
{
fTabFrames[i] = fTab->AddTab(groupNames[i]);
fCanvas[i] = new TRootEmbeddedCanvas(cname,this,400,200);
fTabFrames[i]->AddFrame(fCanvas[i]);
fCanvas[i]->SetContainer(fTabFrames[i]);
}
AddFrame(fTab);

/////////

This generates the Tab correctly, but the resulting canvas does not appear inside the tab environment, but instead it floats freely.

Is there something simple that I’m doing wrong?

Thanks,
Daniel

Hi Daniel,

The parent windows of the TRootEmbeddedCanvas you create are wrong - instead of this you should put the tab container frames, i.e. fTabFrames[i].

///////////

for (int i=0;i<Ntabs;i++)
{
fTabFrames[i] = fTab->AddTab(groupNames[i]);
fCanvas[i] = new TRootEmbeddedCanvas(cname,fTabFrames[i],400,200);
fTabFrames[i]->AddFrame(fCanvas[i]);
fCanvas[i]->SetContainer(fTabFrames[i]);
}
AddFrame(fTab);

/////////

Best regards, Ilka[/code]

Hi Daniel,
look at
$ROOTSYS/tutorials/guitest.C
$ROOTSYS/test/guitest.cxx

It contains an example of TGTab with TRootEmbeddedCanvas.

Regards. Valeriy