TGraph updates only on mouse click

Hey all,

I am building a root based qt application using the TQtWidget class. Right now I am trying to use a TGraph in order to display data points that are acquired in run time.

So far I have not been able to get the graph to update points except upon mouse clicks. I have tried to find the way in which the widget deals with mouse events but have come to no real solid ground.

Sorry if this is a simple issue, I’m new to ROOT :slight_smile:. Any suggestions on how to properly update the graph would be appreciated.


mygraph->DrawGraph(data.size(), &(data[0]), &(data[0]), "A*");

Where this is a TQtWidget and mygraph is a TGraph object works well. In case this would help anyone else.

I am sorry I missed :blush: your post because of the “Stat and Math Tools” section you opted to send your question to. Your issue was the Qt related. Alas, none has called my attention to your trouble.
The better place to ask such sort of question is viewforum.php?f=3

[quote=“pavlovsky”] ...this->Refresh(); [/quote]
Yes, your solution is correct =D> . The TQtWidget as any other QWidget is updated as soon as the " Qt system" updates the widget. For example, the user “resizes” the widget or “clicks” it.
The “Refresh” method was designed to FORCE :bulb: Qt system to update the widget. I would like to call your attention that the Refresh is Qt slot. As such it can be connected to the suitable Qt signal.
One needs to understand how the ROOT “Draw” method works to avoid the frustration.
The Draw method doesn’t draw anything at all. See Understanding two methods: Paint() and Draw() for details

The Draw method doesn’t draw anything at all.[/quote]What does that mean? That means you should invoke any “TObject ::Draw” ( “TGraph::Draw” ) at once to connect the TGraph and the widget. This invocation is not causing any visual change of the widget right away.
Then you can alter your graph ( using SetPoint method, for example) as you need. As soon as you know all graph points are in you call Refresh or use any other Qt approach to “update” the Qt widget.
See for details. Be aware about some optimization. For example, we do not want forcing ROOT to recalculate the TObject graphical representation ( it can be the time consuming operation) as soon as “part of a widget is exposed because a covering widget was moved.”