How to get the pointer of the default canvas in a TBrowser object

Hi,

Is there a way to get the pointer of the default canvas in a TBrowser object. I need to modify the default tab and canvas.

Thanks,
wanting


Please read tips for efficient and successful posting and posting code

_ROOT Version: root6
Platform: Not Provided
Compiler: Not Provided


I think the easiest way is:

TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("Canvas_1");

Thanks, It works.

The further question is when I try to rename the canvas, the title on the TBrowser tab element “Canvas_1” doesn’t change. how can I do if I want rename the tab element?

Regards.

Try:

root [0] TBrowser *b = new TBrowser
root [1] TGString *newName = new TGString("New Name");
root [2] ((TRootBrowser *)b->GetBrowserImp())->GetTabRight()->GetTabTab("Canvas_1")->SetText(newName)
root [3] ((TRootBrowser *)b->GetBrowserImp())->GetTabRight()->Layout()
root [4]

So something like this should work:

TRootBrowser *rb = ((TRootBrowser *)browser->GetBrowserImp());
TGTabElement *el = rb->GetTabRight()->GetTabTab("Canvas_1");
if (el) {
   TGString *newName = new TGString("New Name");
   el->->SetText(newName);
}
rb->GetTabRight()->Layout();

Great, This method is perfect for me.
Thanks again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.