Make closing a TCanvas window close the application

Dear Rooters,

I created a few macros that I use on various root files to plot some histograms. I created a small main function in each source file so that I can make a program out of it or run from inside root.

The main function is inside an #ifndef CINT, instanciates a TApplication and then runs it.

I would like to make it so that when I run the macro as a program, the program exits when I close one of the canvases that are created.

I tried canv->Connect(“CloseWindow()”, “TCanvas”, canv, “gApplication->Terminate()”);
But I got the following error:
Error in TQObject::CheckConnectArgs: signal TCanvas::CloseWindow() does not exist

How can I do this?

I have attached a bit of source that shows what I do.

Greetz, Roel
CanvasClose.C (741 Bytes)


As you noticed, the Canvas::CloseWindow() signal doesn’t exist. Use Canvas::Closed() instead.
Two examples:
If the canvas has already been created and you have its pointer:

canv->Connect("TCanvas", "Closed()", "TApplication", gApplication, "Terminate()");

Otherwise, more generic way:

TQObject::Connect("TCanvas", "Closed()", "TApplication", gApplication, "Terminate()");


That does the trick, thx!

Greetz, Roel