TGCompositeFrame & Tabs


I am implementing tabs in my GUI and I wonder why it is necessary to use the following code (taken from the example file guitest.C):

TGCompositeFrame *tf = fTab->AddTab(“Tab 1”);
fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);

Here we create a pointer (‘tf’) of type TGCompositeFrame that points to the TGCompositeFrame of “Tab 1”. And then we create another TGCompositeFrame (‘fF1’) inside the TGCompositeFrame ‘tf’.

Isn’t it enough to create only ONE TGCompositeFrame?? Why do we need two?

I am looking forward to a solution to this riddle!

Hi Gerolf,

The composite frame returned by AddTab method as the tab container was added with default layout hints - this means that all child widgets you add into it will be laid out top/left vertically with 0 pads from left, right, top, bottom. In the example of guitest.C you can see that the composite frame tf is used as a ‘main’ container.The new composite frames created to hold the child widget of each tab are different - some of them are vertical, other - horizontal and they are added to the parent with different layout parameters.

Let say in short - the main reason is the layout.

Best regards, Ilka