use of deleted function ‘Truck& Truck::operator=(const Truck&)’
Hi, I studied slots/signals so now I am making some practise.
I created the following code to do some tests.
But when I try to compile, I get error message
/usr/include/qt5/QtCore/qmap.h:714: error: use of deleted function ‘Truck& Truck::operator=(const Truck&)’ lastNode->value = avalue; ~~~~~~~~~~~~~~~~^~~~~~~~ ^
Where did I make a mistake? Thank you
QObjects are not copyable by design.
So when you say
QMap<QString, Truck> *trucksCollection;
You will try to copy one into the list when adding a pair.
The normal solution is just to use
QMap<QString, Truck*> *trucksCollection;
But be sure you manage the clean up since you most likely
will not give them a Qt parent to delete them for you.
To add to @mrjj, you don't needed to allocate trucksCollection on the heap. QMap manages its internal state there already.