I am developing a Qt application using ROOT as a plotter. I am using QtRoot (BNL version) with ROOT v5.28.00e on Linux/X11 (because current QtRoot does not compile with ROOT v5.30).
One day I encountered a strange phenomenon; The ROOT canvas embedded with a TQtWidget does not repaint a TGraph correctly when TSpline3 is involved.
I attached the simplest program that reproduces the problem.
The graph is recreated and the canvas is updated when the push button is clicked, but the old graphs remain visible.
This does not occur if the TSpline3 object is not drawn nor when the drawing function is called not via the signal/slot mechanism.
The old graphs disappear when the widget is resized.
[quote=“kame”]I am developing a Qt application using ROOT as a plotter. I am using QtRoot (BNL version) with ROOT v5.28.00e on Linux/X11 (because current QtRoot does not compile with ROOT v5.30)[/quote]Please check the thread: lists.bnl.gov/pipermail/qt-root … 00536.html
[quote=“kame”]One day I encountered a strange phenomenon; The ROOT canvas embedded with a TQtWidget does not repaint a TGraph correctly when TSpline3 is involved.[/quote]I’ll check your example and come back shortly.
Thank you
delete g;
g = new TGraph(10);
@@ -32,9 +33,8 @@
s->SetLineColor(kRed);
s->SetLineWidth(2);
s->Draw(“same”);
w->GetCanvas()->Modified();
w->GetCanvas()->Update();
w->Refresh();
update();
}[/code]Please, check whether it helps you. ( I compiled it against of ROOT 5.30 ). Be aware that the Draw method appends the pointer of your object to the TPad “list of primitives”. The TPad may delete the object for you. This may cause your program to crash as soon as it tries to delete “g” or “s” for the second time with your “delete s;delete g;” Use “http://root.cern.ch/root/html528/TPad.html#TPad:GetListOfPrimitives” to be safe. Check root.cern.ch/root/html528/src/TO … html#EOrTy for details.
Hi, thank you very much for detailed instruction.
Thank you also for the information to compile QtRoot with ROOT v5.30.
Unfortunatelly, the problem does not disapper in my system. The deleted graphs are still displayed. I compiled the program with ROOT v5.30.01.
I attached again my sources modified as you suggested. (Sorry for attaching Makefile instead of *.pro file before.)
Thank you for pointing that out. Now the code is safe because I added TObject::SetBit(kCanDelete, kFALSE), right? test2.tar (10 KB)
I have not been able to reproduce your issue yet, Sorry.
Can you check another thread; TGraph updates only on mouse click ?
Can you try to use TPad::Clear rather “delete s ; delete g” to see whether your problem persists.
I added w->GetCanvas()->Clear(); or w->GetCanvas()->GetPad(0)->Clear(); before drawing, but the canvas is not cleared. (Actually I had tried this before posting.)
Let me confirm again; in your environment, is the canvas correctly updated when the button is clicked two or more times in a row?
By the way, I am using Qt 4.7.3. Are you too?
I updated ROOT to v5.34.03, then above solution seems no longer effective.
That is, disabling GetPainter()->SetFillStyle(0) in TPad::PaintBox(…) method (see blow) does not fix the problem any more.
void TPad::PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option)
{
// Paint box in CurrentPad World coordinates.
//
// if option[0] = 's' the box is forced to be paint with style=0
// if option[0] = 'l' the box contour is drawn
if (!gPad->IsBatch()) {
Int_t style0 = GetPainter()->GetFillStyle();
Int_t style = style0;
if (option[0] == 's') {
GetPainter()->SetFillStyle(0);
style = 0;
}
if (style) {
....
Well since the fix was not accepted ( savannah.cern.ch/bugs/index.php?80560 ) someone might have done the same thing elsewhere. Just an extra job (and time) to find it.
Sorry, I have no solution to address your last issue. However, the report savannah.cern.ch/bugs/?99855 indicates that we may be facing some new " FillStyle/FillColor" issue to be investigated indeed