How to clear a TGGroupFrame

Hi everybody,

I am using a TGGroupFrame with a TGTableLayout to display a matrix of values: the rows are different “properties” and the columns are the different channels of my equipment.
Both the number of “properties” and the number of channels depend on the specific model I’m connecting to.

I would like to fill the matrix when I connect, and empty the matrix when I disconnect from hardware.

What I’m doing right now is

TGFrameElement *el; TIter next(tggroup_channels->GetList()); while ((el = (TGFrameElement *) next())) { tggroup_channels->HideFrame(el->fFrame); tggroup_channels->RemoveFrame(el->fFrame); delete el->fFrame; }
however, in this way the lower border of TGGroupFrame disappears; it looks like it’s covered by something with the same color as the background of the window.

I found a lot of methods with promising names, line Clear(), RemoveAll(), RecursiveRemove(), Cleanup(), but none of them works as I want. Sometimes the values are hidden, but the space is still “occupied” in some way; or the lower border is missing / covered, or the values all disappear but the first…

Is there a simple way to completely clear a frame, meaning to put it in the same condition as it was just after declaration and first show? :unamused:

Thank you in advance :smiley:

Hi Davide,

I could probably find a solution, but if you have a running macro to start from, that would save some time… (but I’ll look at this tomorrow anyway)

Cheers, Bertrand.


I cannot reproduce the problem. Could you post a running macro showing this behavior?
And BTW, ROOT version? OS? compiler?

Cheers, Bertrand.

Thank you for trying. I hoped that I was missing a simple solution; I’ll prepare a short code to reproduce the problem (and/or attaching screenshots).

Root 5.34/18, Ubuntu 14.04, gcc version “something”… you are right, I’ll be more specific :wink:


I’m attaching a copy of my GUI with only the relevant parts included.

After compiling and launching the application, try to “Connect” and “Disconnect” a couple of of times, and see how the lower border of the TGGroupFrame gets covered, entirely or in part.

Now I’m writing from my home computer and the result is slightly different, but the problem is always the lower border being covered.

On both machines I’m using Ubuntu 14.04 and ROOT 5.34/18; here gcc is version 4.8.2.
mwe.tar.gz (2.74 KB)


Add “el->fFrame->DestroyWindow();” in your loop:

void HVManager::RemoveLabels() { TGFrameElement *el; TIter next(tggroup_channels->GetList()); while ((el = (TGFrameElement *) next())) { tggroup_channels->HideFrame(el->fFrame); tggroup_channels->RemoveFrame(el->fFrame); el->fFrame->DestroyWindow(); delete el->fFrame; } }
And BTW, if your HVManager class inherits from TGMainFrame, you don’t need “RQ_OBJECT(“HVManager”)” and you don’t need “TGMainFrame *mainframe_main;” (right now you are constructing two TGMainFrames…). See your example, with several modifications:mwe-2.tar.gz (2.72 KB)
Cheers, Bertrand.

Thank you very much, it works perfectly!

Also the hint about inheritance and TGMainFrame was very helpful :smiley: