I have a QVector in which I'm constantly appending data so I can plot on a QwtPlot. But with a high frequency I guess the vector becames too large and the program crashes.

My question is, how can I create a QwtCurve which is only beggining in some point of time, bacause the time that has already passed is not necessary in the vector as it was already plotted.

here's my code:

Qt Code:
  1. QVector<double> xv;
  2. QVector<double> cv1;
  3. QVector<double> cv2;
To copy to clipboard, switch view to plain text mode 

as global variables,

Qt Code:
  1. void gui::process_new_info(QByteArray array)
  2. {
  3. int v = 0;
  4.  
  5. double f = ui->frequency->value();
  6.  
  7. xv.append(sizeof_array/f);
  8.  
  9. char *buf = array.data();
  10.  
  11. if (ui->ecgPlux->isChecked() == true || ui->channel_1->currentIndex() != 0)
  12. {
  13. cv1.append(buf[1]);
  14.  
  15. QwtPlotCurve *curve1 = new QwtPlotCurve;
  16. curve1->attach(plot_all[0]);
  17. curve1->setData(xv,cv1);
  18. curve1->setPen(QPen(Qt::blue,1));
  19. plot_all[0]->replot();
  20.  
  21. QwtPlotCurve *curve2 = new QwtPlotCurve;
  22. curve2->attach(plot[0]);
  23. curve2->setData(xv,cv1);
  24. curve2->setPen(QPen(Qt::blue,1));
  25. plot[0]->replot();
  26. }
  27.  
  28. if (ui->xyzPlux->isChecked() == true || ui->channel_2->currentIndex() != 0)
  29. {
  30. cv2.append(buf[2]);
  31.  
  32. QwtPlotCurve *curve3 = new QwtPlotCurve;
  33. curve3->attach(plot_all[1]);
  34. curve3->setData(xv,cv2);
  35. curve3->setPen(QPen(Qt::blue,1));
  36. plot_all[0]->replot();
  37.  
  38. QwtPlotCurve *curve4 = new QwtPlotCurve;
  39. curve4->attach(plot[1]);
  40. curve4->setData(xv,cv1);
  41. curve4->setPen(QPen(Qt::blue,1));
  42. plot[1]->replot();
  43. }
  44.  
  45. //printf ("%d ->", buf[0]);
  46. fprintf (data, "%d,", buf[0]);
  47.  
  48. for (int i = 1; i < 9; i++)
  49. {
  50. v = buf[i];
  51. //printf ("%d,", v);
  52. fprintf (data, "%d,", v);
  53. }
  54.  
  55. //printf ("\n");
  56. fprintf (data, "\n");
  57.  
  58. sizeof_array++;
  59. }
To copy to clipboard, switch view to plain text mode