Hi,

I would like to plot multiple curves on one qwtplot object.



Qt Code:
  1. QwtPlotCurve* mycurve = new QwtPlotCurve("curve1");
  2. QwtPlotCurve* mycurve2 = new QwtPlotCurve("curve2");
  3.  
  4. QwtPointSeriesData* myData = new QwtPointSeriesData;
  5. QVector<QPointF>* samples = new QVector<QPointF>;
  6. samples->push_back(QPointF(time->at(0), samplesPerUser[0]));
  7. //creating histogram
  8. for (int i=1; i<30; i++) {
  9. samples->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser[i]));
  10. samples->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser[i+1]));
  11. }
  12. samples->push_back(QPointF(time->at(30), samplesPerUser[30]));
  13.  
  14. myData->setSamples(*samples);
  15. mycurve->setData(myData);
  16. mycurve->attach(plot);
  17.  
  18. QwtPointSeriesData* myData2 = new QwtPointSeriesData;
  19. QVector<QPointF>* samples2 = new QVector<QPointF>;
  20. samples->push_back(QPointF(time->at(0), samplesPerUser2[0]));
  21. //creating histogram
  22. for (int i=1; i<30; i++) {
  23. samples2->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser2[i]));
  24. samples2->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser2[i+1]));
  25. }
  26. samples->push_back(QPointF(time->at(30), samplesPerUser2[30]));
  27.  
  28. myData->setSamples(*samples2);
  29. mycurve->setData(myData2);
  30. //making the second curve red
  31. mycurve2->setPen(QPen(Qt::red));
  32.  
  33. mycurve2->attach(plot);
To copy to clipboard, switch view to plain text mode 

The problem is that I can see only the second curve, not the first one. I'm not sure whether creating 2 QwtPlotCurve object and attaching them to the plot is a right approach.