Hi,

This is my first post on this forum. First, I shall start off by saying that I'm a first year Electrical Engineering student, and am learning Qt, I'm not by any means, a pro at Qt (or C++) for that matter.

I made a program that receives and digital voltages read from this device connect to the serial port. Now I have to plot it.

I've managed to make basic plots, like sine waves and stuff like that. I would like to plot in realtime though. I know that the Oscilloscope and Realtime examples provided in Qwt 6.0.1 illustrate how to do this. I've read the DOC a lot as well. I'm having trouble understanding how to perform this realtime plotting.

I've made a trivial program to illustrate my issue. The points (-5, 5), (8, 7)... having nothing to do with anything. I just arbitrarily chose them as an example.
Qt Code:
  1. testQwt::testQwt(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
  2. {
  3. ui.setupUi(this);
  4.  
  5. ui.qwtPlot->setAxisScale(QwtPlot::xBottom, -10, 10);
  6. ui.qwtPlot->setAxisScale(QwtPlot::yLeft, -10, 10);
  7.  
  8. painter = new QwtPlotDirectPainter();
  9.  
  10. curve1 = new QwtPlotCurve;
  11. curve1->attach(ui.qwtPlot);
  12.  
  13. std::vector<double> times1;
  14. std::vector<double> times2;
  15. std::vector<double> data1;
  16. std::vector<double> data2;
  17.  
  18. times1.push_back(-5);
  19. times1.push_back(8);
  20.  
  21. data1.push_back(5);
  22. data1.push_back(7);
  23.  
  24. curve1->setSamples(&times1.front(), &data1.front(), data1.size());
  25.  
  26. times2.push_back(0);
  27. times2.push_back(3);
  28.  
  29. data2.push_back(2);
  30. data2.push_back(3);
  31.  
  32. painter->drawSeries(curve1, 0, 1);
  33. }
To copy to clipboard, switch view to plain text mode 

I don't understand why 'drawSeries' doesn't seem to do anything. All I would like to do is, add some more points (connected by a line) to the plot. Perhaps I'm going completely incorrectly about this; perhaps I just have a small error -- I have no idea. I will be plotting hundreds of thousands of points very often, and would like to augment to the plot rather than 'replot()' (which I believe is expensive, as it plots the whole thing) the whole thing.

If someone could point me in the right direct, that'd be great.

Thank you for your time.