Hello,

I'm trying to make a plot which updates dynamically like in cpuplot example of QWT.
Everything goes fine excepted that when I'm trying to set new datas with setRawSamples in Qt's timer I experiment read violation access. Here is my sample class :

Qt Code:
  1. #include "StdAfx.h"
  2.  
  3. QTimeStepView::QTimeStepView(QWidget *parent)
  4. : QwtPlot(parent)
  5. , count(0.0)
  6. {
  7. {
  8. m_x.push_back(count);
  9. m_y.push_back(count);
  10.  
  11. count +=1;
  12.  
  13. m_x.push_back(count);
  14. m_y.push_back(count);
  15.  
  16. count +=1;
  17.  
  18. m_x.push_back(count);
  19. m_y.push_back(count);
  20.  
  21. count +=1;
  22. }
  23. this->setAutoReplot(false);
  24.  
  25. // Show a title
  26. setTitle( "This is an Example" );
  27.  
  28. // Show the axes
  29. setAxisTitle( xBottom, "Time" );
  30. setAxisTitle( yLeft, "Timestep" );
  31.  
  32. QwtPlotCurve *m_timestep = new QwtPlotCurve("timestep");
  33. m_timestep->attach(this);
  34. replot();
  35.  
  36. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size());
  37. replot();
  38.  
  39. {
  40. m_x.push_back(count);
  41. m_y.push_back(count);
  42.  
  43. count +=1;
  44. }
  45. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size());
  46. replot();
  47.  
  48. (void)startTimer(1000);
  49. }
  50.  
  51. QTimeStepView::~QTimeStepView()
  52. {
  53.  
  54. }
  55.  
  56. void QTimeStepView::timerEvent(QTimerEvent* event)
  57. {
  58. m_x.push_back(count);
  59. m_y.push_back(count);
  60.  
  61. count +=1;
  62.  
  63. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size()); //Here happens the error
  64. replot();
  65. }
To copy to clipboard, switch view to plain text mode 

Severals setRawSamples goes fine in constructor but if I try to make it in the timer it doesn't work.