Need help with TGListTree

Hi All,

I am trying to write a GUI and want to use TGListTree, but my root macro segfaults. Can anyone point out what am I doing wrong in the example below?

I am actually trying to put a browser inside a frame, if anyone could hint me how… that wuld be better.

thanks in advance,

class TestListTree{



     TGMainFrame*          fMain;

 TGHorizontalFrame*    hframe;


     TestListTree(const TGWindow* p, UInt_t w, UInt_t h);
     virtual ~TestListTree();


TestListTree::TestListTree(const TGWindow* p, UInt_t w, UInt_t h)
fMain = new TGMainFrame(p, w, h);
hframe = new TGHorizontalFrame(fMain, 800, 600);

TGListTree* listtree = new TGListTree(hframe, 200, 600, kSunkenFrame);

gDirectory->mkdir(“new directory”);
gDirectory->cd(“new directory”);
//TH1* th = new TH1(“th”, “an empty 1d histo”, 20, 50, 100);
TGListTreeItem* item = listtree->AddItem(0,“ROOT Memory”);

fMain->AddFrame(hframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));

fMain->SetWindowName(“TListTree Test”);





delete fMain;

void testlisttree()
new TestListTree(gClient->GetRoot(), 800, 600);


Hi Aram,
please check $ROOTSYS/tutorials/guitest.C $ROOTSYS/test/guitest.cxx
(TestDirList class). Please, also try to provide backtrace seg.fault.

With the latest ROOT you can easily embed any frame into
some composite frame. This technique is used for example in
new canvas editor.

For your case it could be done as:

 TGCompositeFrame *hframe;
 new TBrowser(); // browser will be embedded into hframe

Regards. Valeriy

just another hint. You do not delete listtree object in
TestListTree destructor. Use LIFO (last in first out) rule
for deallocation of resources.

Regards. Valeriy

Hi Valeriy,

TestDirList class and TestFileList classes were not available in guitest.C of version 3.05. I just installed 4.04.

and the ability to embed frames into composite frames ofcourse makes my life alot easier :smiley:
thanks again,