I am migrating a project from Qt4 to Qt5, in fact I have finished migrating it but now I have to migrate the libraries, and I have encountered a problem that I cant figure out:
..\qenc\ShapeLandPOI.cpp: In member function 'virtual void ShapeLandPOI::draw(QPainter*)':
..\qenc\ShapeLandPOI.cpp:74:92: error: no matching function for call to 'QMap<QString, ShapeAttribute>::iterator::iterator(QMap<QString, ShapeAttribute>::const_iterator)'
AttributeSet::iterator vItPOI = (AttributeSet::iterator)attributes.at(i).find("POI");
note: candidates are:QMap<Key, T>::iterator::iterator(QMap<Key, T>::Node*) [with Key = QString; T = ShapeAttribute; QMap<Key, T>::Node = QMapNode<QString, ShapeAttribute>]
inline iterator(Node *node) : i(node) { }
^
After that one I get another error below, but I think once the error above is solved this one wont be a problem, although it might help to know whats going on:
..\..\..\..\..\Qt5\5.2.1\mingw48_32\include\QtCore/qmap.h:423:16: note: no known conversion for argument 1 from 'QMap<QString, ShapeAttribute>::const_iterator' to 'QMap<QString, ShapeAttribute>::Node* {aka QMapNode<QString, ShapeAttribute>*}'
..\..\..\..\..\Qt5\5.2.1\mingw48_32\include\QtCore/qmap.h:422:16: note: QMap<Key, T>::iterator::iterator() [with Key = QString; T = ShapeAttribute]
inline iterator() : i(0) { }
^
these are the two lines giving problems:
AttributeSet::iterator vItPOI = (AttributeSet::iterator)attributes.at(i).find("POI");
AttributeSet::iterator vItPOI0 = (AttributeSet::iterator)attributes.at(i).find("POI0");
I honestly dont know how to correct these lines so they match the candidate functions suggested. I hope someone can throw some light on the subject. Thankyou.
EDIT: I have tried using static_cast instead but its still the same error.
I solved it by turning
into
and changing very little part of the code, for example I had
and changed it to
So the functionality should stay the same. I was lucky because the variable was only use to get the string value of the shape attribute, except for a few ifs I didnt have to do change much.