How To Update TEmbedded Canvas


I am writing a GUI that utilizes a TEmbeddedCanvas in a TGMainFrame object. When I create and draw my graph to the TEmbeddedCanvas, it is not displayed. However, when I resize the window (by dragging the sizing controls), the window is updated and I see the graph. How do I force the display of the graph in the TEmbeddedCanvas automatically. I tried DoRedraw and that didn’t seem to have any effect.

Thanks in advance.


Hi Jon,

What you need is to update the canvas. Please find below an example where fEcan is the embedded canvas pointer.

Best regards, Ilka

TCanvas *c1 = fEcan->GetCanvas(); // fEcan is the embedded canvas pointer

const Int_t n = 20;
Double_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i0.1;
y[i] = 10
printf(" i %i %f %f \n",i,x[i],y[i]);
gr = new TGraph(n,x,y);
gr->SetTitle(“a simple graph”);
gr->GetXaxis()->SetTitle(“X title”);
gr->GetYaxis()->SetTitle(“Y title”);

// TCanvas::Update() draws the frame, after which it can be changed

Thanks. This helped and worked. I am wondering whether you know whether using QT provides any enhancements to creating GUIs that is not available in ROOT itself?


[quote=“jon149”]Thanks. This helped and worked. I am wondering whether you know whether using QT provides any enhancements to creating GUIs that is not available in ROOT itself?


Yes, my believe Qt does provide a lot of enhancements and what is essential it rather stable and robust environment

The main advantage of working with Qt is the time saving:

  1. Qt-based GUI code is generally much shorter hence less time to write, less chances to make a mistake
  2. Qt provides a lot of ready-to-use Widget. Some of them are included in the distribution others can be downloaded form the various Web sites.
    If you are going to work on Linux then you can enjoy the KDE environment that comes with hundreds of well designed and thoroughly debugged widgets.
    see examples
  3. You can use Qt Designer (or KDesinger … signer.png in case of the KDE env) as result the most complex part of the code will be written for automatically and you can devote your time to polish your concrete algorithm you are create the GUI for.

As result as soon as you have a clear idea how your GUI should look and behave like you can create an working inter4face in a day.
To prove that I am willing to create one for you. If you havegot a clear idea about your GUI and can describe this idea the can have created a Qt project and generate the working version of GUI. So you will have something you can start to work with.

You can find the further information on Web site

Look for

I would advice to download and install the Windows version of ROOT with Qt layer.
It should take you about 5 min to download and play with the several examples that distribution contains.
(for example )

Don’t hesitate asking me any further information you may have got.

The Web page
contains another example of the complex Qt-based application.

Hope this help

Feell free to send me the questions you may have directly

I did highlihg some additions those ROOT with Qt layer has benefit just because of the Qt layer involved.


Thanks for your very informative response. I am trying to understand the best solution. What is the difference between KDE and Qt? Are they based on the same engine. I am hoping to develop a solution that will run under Linux as well as MacOS 10.x. I understand that Qt is available for boh platforms. However, is KDE only Linux specific? Is there any way that I can take advantage of the Aqua interface under MacOs?

By the way, i have really started to get into the intrinsics of Root and am very impressed with the framework you have developed. It is absolutely fantastic.


Best Regards,