Hai,

I am newbie to QT as well as Qwt.

I am having QT 5.0.2, QT Creator 2.7.0 and Qwt 6.1.0.

My requirement is Plotting the graph for the data is continuous data in real time, this data is reding from background process.


According to my application, I am started the background process using QProcess that process is .exe file for C code. In this C code ther is a while(1) loop for reading Infinite data. In GUI I am able to read the data also.

Now I want to plot the graph for those values to find the deviation.

I have simple qwt code as below

Qt Code:
  1. float y[20], x[20];
  2. int i;
  3. for(i=0;i<20;i++)
  4. {
  5. x[i]=i;
  6. y[i]=2*sin((x[i]));
  7.  
  8. }
  9. QwtPlot *plot=new QwtPlot();
  10. plot->setTitle( "Plot Demo" );
  11. plot->setCanvasBackground( Qt::white );
  12. //plot->setAxisScale( QwtPlot::yLeft, 0.0, 20.0);
  13. // plot->setAxisScale(QwtPlot::xBottom, 0.0, 20.0);
  14. plot->insertLegend( new QwtLegend() );
  15. plot->setAxisTitle(QwtPlot::xBottom, "X Axis");
  16. plot->setAxisTitle(QwtPlot::yLeft, "Y Axis");
  17. QwtPlotGrid *grid = new QwtPlotGrid();
  18. grid->attach( plot );
  19. grid->setPen( Qt::gray, 0.0, Qt::DotLine );
  20.  
  21. QwtPlotCurve *curve = new QwtPlotCurve();
  22. curve->setTitle( "Pixel Count" );
  23. curve->setPen(QPen(Qt::blue, 3,Qt::SolidLine) ),
  24. curve->setRenderHint( QwtPlotItem::RenderAntialiased, true);
  25.  
  26. QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,QBrush(Qt::yellow),QPen(Qt::red,2),QSize(8,8));
  27. curve->setSymbol(symbol );
  28.  
  29. QPolygonF points;
  30. for(i=0;i<20;i++)
  31. points<<QPointF(x[i],y[i]);//<<QPointF(x2,y2)<<QPointF(x3,y3)<<QPointF(x4,y4)<< QPointF(x5,y5);
  32. curve->setSamples( points );
  33. curve->attach(plot );
  34. plot->replot();
  35. plot->resize( 600, 400 );
  36.  
  37. plot->show();
To copy to clipboard, switch view to plain text mode 

and code for reading the background data

Qt Code:
  1. QList<QByteArray> read_data;
  2.  
  3. b1= process->readAllStandardOutput();
  4.  
  5. read_data=b1.split('\n');
  6. int i=0,n=read_data.count();
  7. float y[100000];
  8. for(i=0;i<n;i++)
  9. {
  10. QString result=read_data.at(i);
  11. result.remove(0,10);
  12. qDebug("%s",result.toLatin1().data());
  13. y[i]=result.toLatin1().toFloat();
  14. }
To copy to clipboard, switch view to plain text mode 

how can I send the data in y[i] to "QPolygonF points"

tried to send to QPolygonF but am not getting what I want.

any one can give suggetions to meet my requirment

Thanks in advance