Repainting TQtWidgets

greetins all,

so i am working on a Qt based data browser that displays ROOT plots, where the user can press either a “next” or “previous” button and view various plots relevent to the data.

right now, my main issue is that when i setp through the data, the new plot is drawn on top of the previous one. the first thing i tried was calling

MyWidget->GetCanvas()->Clear(); //MyWidget is an instance of TQtWidget MyWidget->GetCanvas()->Modified(); MyWidget->GetCanvas()->Update();

in that order, before i called the functions responsible for drawing on the embeded canvas. this has no effect at all. i have also tried calling TQtWidget::Erase() but to no avail.

MyWidget is the only embeded canvas in the application, but just to be safe all functions that operate on the canvas first call MyWidget->GetCanvas()->cd().

how do i repaint my embeded canvas?

Thanks!
Gus

shameless bump…

well i fixed the issue and you aren’t going to like it…

i made a bare bones replica of my application (empty widget, just two buttons and my TQtWidget instance. didn’t set any styles or astetics, plotted sample data of identical format) and it worked fine… i was able to clear and update the canvas within TQtWidget without any issue. then i started slowly adding more to my code, in order to systematically identify where the problem occured.

i found that the issue origionated from this line…

MyWidget->GetCanvas()->SetFrameBorderMode(0);

as soon as i added this line, my canvas would not repaint, and all aditional plotting would be placed on top of old plots… commenting this line out removed the problem…

so! thats it then i guess… i am going to try and isolate the issue in some simple code and submit a but report when i can.

Can you upload some working example that one can use to reproduce your trouble ? Some information about your environment, platform, versions. compiler may help as well.

[quote=“Gus”]… to be safe all functions that operate on the canvas first call MyWidget->GetCanvas()->cd().
…[/quote]It is NOT safe approach. It is, in fact, the race condition prone approach. That may entail some sort of dead-lock. “TPad::cd” method is to invoke “Update” internally . As result, you may end up calling “Update” from within “Update” infinitly. You should minimize the use of “cd” method just to increase the performance of your application.

It seems to me you turned off the TCanvas / TPad double buffering mode at some point within your application. Can you check that?

[quote=“Gus”]greetins all,

MyWidget->GetCanvas()->Clear(); //MyWidget is an instance of TQtWidget MyWidget->GetCanvas()->Modified(); MyWidget->GetCanvas()->Update();
[/quote]The right way is to call MyWidget->Erase()It should be sufficient.

[quote=“Gus”]… MyWidget is the only embeded canvas in the application[/quote]Is your application “Qt application” or “ROOT application”. In the other words, did your “main” entry instantiate the QApplication or TApplication ?

Can you check whether your trouble and
savannah.cern.ch/bugs/?72522
root.cern.ch/root/roottalk/roottalk10/1036.html are related ?