Add multiple button in frame

i have made the method below that is called throught an item in the menu of a GUI interface; scope is that each time the user make a specific action this method should add another check box inside the TGVerticalFrame that is the owner class of this method. Everything works fine the first time i call the method, but each successive calls overwrite the first one; so i have a frame with always only one checkbox instead of a vertical list of them. Why?


void PFrame::updateUsedFiles(){
new TGCheckButton(this, new TGHotString(PModel::getInstance()->getPFile()));
MapSubwindows(); // to draw the contents

Hi Maurizio,

You need to add any new widget you create to the list of its parent frame via the method AddFrame(frame, layout_hints).

AddFrame( new TGCheckButton(this, new TGHotString(PModel::getInstance()->getPFile())),
new TGLayoutHints(/parameters you want to use here/);

Cheers, Ilka

Thanks! It works :slight_smile: