I have a QList which I have inserted pointers of objects into. I am trying to iterate through this QList to read the name of these objects. Whenever I do so, I am getting the address of these objects as oppose to reading the object name itself. I am wondering how would I be able to read the object name instead of the address?
QList<MyObject*> newObjectList;
QList<MyObject*>::iterator i;
MyObject *pNewObject = new MyObject(name);
MyObject.append(pNewObject);
for (i = newObjectList.begin(); i != newObjectList.end(); i++) {
cout << "\n" << *i << "\n";
}
When you’re dereferencing i, you need to call the function to get the name from your object. Something like this: