Hello,
I have a QwtPlotCurve attached to QwtPlot. The curve is made up of a large number of QPointF's. I want to keep only one copy of these points in memory(so I need to avoid deep copies). Hence I chose QwtPointSeriesData(Vector<QPointF>&). I use QwtPlotCurve::setSamples() to make sure my curve reflects any changes that happen to the vector of points. I provide appropriate boundingRect() and everything works fine.
Code snippet:
Qt Code:
QVector<QPointF> m_2dPointsVector; curve1->setSamples(QwtPointSeriesData(m_2dPointsVector));To copy to clipboard, switch view to plain text mode
I want to use Qt's Model-View pattern and create a Graph which acts like my View. The graph which is a QWidget has a child QwtPlot. Create a QAbstractListModel to hold the data: QVector<QPointF> m_2dPointsVector;. Everytime this data changes the QwtPlotCurve updates itself as I described before. But to reflect this change in my Graph I need to listen to the dataChanged() signal from the QAbstractListModel. Inside the slot I call the QwtPlot::replot(). This works fine!
My Question is:
I think I am not doing it right since the graph is a normal widget which has a pointer to the QAbstractListModel and listen's to its dataChanged() signal. Is there a cleaner way of doing this so that I can make the best use of Qt's Model-View pattern?
Bookmarks