Hi, I've been working with the Qt library on C ++ for a while now and I'm getting the following problem:
Given a class named "project.h" I define a list as follows QList<Capa*> datosCapas;
.
Following this, I proceed to load the list with the void addDataLayer (Capa* unaCapa);
method. Basically what this method does is the following
void proyecto::addDataLayer(Capa* unaCapaFromXml){
this->datosCapas.append(unaCapaFromXml);
}
At the moment of wanting to print the data by console, using a qDebug()
and in this way to make sure that the list I have loaded the data I need. It occurred to me to implement the following:
void proyecto:: imprimirLista(){
QListIterator<Capa*> iteratorCapas(this->datosCapas);
Capa objetoCapa;
while(iteratorCapas.hasNext()){
objetoCapa = iteratorCapas.next();
qDebug() << objetoCapa.getH() << "|" << objetoCapa.getHNeta() << "|" << objetoCapa.getPorosity();
}
}
The problem is that there is an incompatibility at the time of iterating the list, precisely because it is pointers.
error: no match for 'operator=' (operand types are 'Capa' and 'Capa* const')
objetoCapa = iteratorCapas.next();
^
How should I work it so I can print the data without problems?
Pd: If you ask me why I add a smart pointer to the bone list (
Capa* unaCapaFromXml
)
is because unaCapaFromXml is the parameter I use to store an object of type Layer, that is, at one point in the program I make an instance of the layer object, that is, new Capa(parámetro1,parámetro2,parámetro3)
.
Greetings.