QList of QwtPlotCurve s | remove QwtPlotCurve from QwtPlot
I would like to make a QList of QwtPlotCurve s. The reason for this is to be able to remove them later form my QwtPlot. I have the following code:
Code:
QList<QwtPlotCurve> myList = new QList<QwtPlotCurve>;
curves->append(curve1);
curves->append(curve2);
The code doesn't compile and the compiler outputs:
error: conversion from 'QList' to non-scalar type 'QList' requested
error: no matching function for call to 'QList::append(QwtPlotCurve&)' void QList::append(const T&) [with T = QwtPlotCurve]
note: candidates are:
note: void QList::append(const T&) [with T = QwtPlotCurve]
note: no known conversion for argument 1 from 'QwtPlotCurve*' to 'const QwtPlotCurve&'
note: void QList::append(const QList&) [with T = QwtPlotCurve]
note: no known conversion for argument 1 from 'QwtPlotCurve*' to 'const QList&'
...
It says the QwtPlotCurve should be constant, but I don't know how to deal with it. I don't know neither whether storing curves in a QList and then removing it (on user demand) from the plot is the right approach.
Re: QList of QwtPlotCurve s | remove QwtPlotCurve from QwtPlot
Change
Code:
QList<QwtPlotCurve> myList = new QList<QwtPlotCurve>;
to
Code:
QList<QwtPlotCurve*> myList = new QList<QwtPlotCurve*>;
You are declaring pointers, but you are trying to store them to a list of objects.