Answer the question
In order to leave comments, you need to log in
How to work with QList correctly?
We have a classic template program in Qt5, that is, there are files main.cpp, name.h, name.cpp.
In the file name.h there is a class app from qmainwindow, in it
private:
...
QList<QwtPlotCurve> *graph;
graph = new QList<QwtPlotCurve>[10];
for(int i=0; i < graph->size(); i++)
{
}
graph[i].attach(ui->graphWidget);
No member named 'attach' in 'QList<QwtPlotCurve>'
, although QwtPlotCurve has such a method. graph->at(i).attach(m_ui->graphWidget);
'this' argument to member function 'attach' has type 'const QwtPlotCurve', but function is not marked const
. Answer the question
In order to leave comments, you need to log in
It is possible like this:
private:
QList<QwtPlotCurve> graph;
for(int i=0; i < 10; i++)
{
QwtPlotCurve curve;
carve.attach(…);
graph.push_back(curve);
}
You've new QList<QwtPlotCurve>[10];
created an array of 10 lists here. Are you sure this is what you wanted?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question