Hi,

I am having trouble draw a polyline from a vector of QPointF which is calculated in another class "getAvgHighTempVec".

Here is my code:

Qt Code:
  1. // main.cpp
  2. size_t qpoint_size = c.getAvgHighTempVec().size();
  3. QVector<QPointF> points(qpoint_size);
  4.  
  5. for(size_t i=0; i < qpoint_size; i++){
  6. points[i].setX(i);
  7. points[i].setY(c.getAvgHighTempVec().at(i));
  8. }
  9.  
  10. weatherStationGUI.draw(points);
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //weatherstationgui.h
  2. namespace Ui {
  3. class weatherstationgui;
  4. }
  5. class weatherstationgui : public QMainWindow
  6. {
  7. Q_OBJECT
  8.  
  9. public:
  10. explicit weatherstationgui(QWidget *parent = 0);
  11. ~weatherstationgui();
  12.  
  13. void draw( QVector<QPointF> dataIn);
  14.  
  15. private:
  16. Ui::weatherstationgui *ui;
  17.  
  18. QVector<QPointF> wellData;
  19.  
  20. protected:
  21. // paint method
  22. void paintEvent(QPaintEvent *event);
  23. };
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //weatherstationgui.cpp
  2. void weatherstationgui::draw(QVector<QPointF> dataIn){
  3. wellData = dataIn;
  4. update();
  5. }
  6.  
  7. void weatherstationgui::paintEvent(QPaintEvent *event){
  8.  
  9. // create a painter
  10. QPainter painter(this);
  11.  
  12. painter.drawPolyline(wellData.data(), static_cast<int>(wellData.size()));
  13. }
To copy to clipboard, switch view to plain text mode 

In the debugger I can see 'wellData' indeed has the correct QPointF points values, but it just doesn't draw on the main window.

Is there anything wrong with my code?

Thanks