PDA

View Full Version : real time graph plot



robotics
22nd May 2011, 15:46
hi Every body I want to plot real time 2D graph
example some value in y-axis and some value in Y-axis
How to do this
please help
Every help shall be appreciated

robotics
22nd May 2011, 19:49
Ok I managed to download the QWT library and build it
can someone provide simple example just ...a simple plot that indicate that my I am able to plot ....
please someone might have done this..

Kangs
22nd May 2011, 20:40
There are several examples with Qwt. For your needs, check cpuplot and oscilloscope.

robotics
23rd May 2011, 17:20
I tried the examples but they are not helping me:(
can u suggest any one of the classes that I can start with

Kangs
23rd May 2011, 19:04
Why these examples do not help you ?
cpuplot is very simple, try to modify it for your needs,
it's just 4 curves updated with a timer.

vangaurd
24th May 2011, 06:04
Hi..All you need to do is re-implement widgets paintevent() with your real time data. Mostly you may need to use drawLine() function of QPainter.
sample logic:


QList<QPair<double,double> > realData; //initialize with ur data
void paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QPen(QColor(200,100,0)));
for(int i=0; i<realData.count()-1; i++)
{
painter.drawLine(QPointF(realData.at(i).first,real Data.at(i).second),QPointF(realData.at(i+1).first, realData.at(i+1).second));
}
}


You can check the sample codes and qt documentation for custom painting.