2014-05-06 84 views
1

我正在将项目从Qt4迁移到Qt5,实际上我已完成迁移,但现在我必须迁移这些库,并且遇到了一个问题,弄清楚:将项目从qt4迁移到qt5时没有匹配的调用函数

..\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) { } 
       ^

一个我得到下面的另一个错误后,但我认为一旦上述错误的解决了这一不会是一个问题,尽管它可能有助于知道怎么回事:

..\..\..\..\..\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) { } 
       ^

这些是给出问题的两条线:

AttributeSet::iterator vItPOI = (AttributeSet::iterator)attributes.at(i).find("POI"); 
AttributeSet::iterator vItPOI0 = (AttributeSet::iterator)attributes.at(i).find("POI0"); 

我诚实地不知道如何纠正这些行,以便它们匹配建议的候选功能。 我希望有人能够对这个问题有所了解。 Thankyou。

编辑:我已经尝试使用static_cast来代替,但它仍然是相同的错误。

+0

Qt不喜欢你使用C风格明显 –

+0

@ratchetfreak但它不是我的错,我没有代码它:(这就是为什么我们不能有好东西 – dasjkdj

回答

0

我解决它通过旋转

AttributeSet::iterator vItPOI = (AttributeSet::iterator)attributes.at(i).find("POI"); 

ShapeAttribute vItPOI = attributes.at(i).find("POI").value(); 

和更改代码的很少一部分,例如我有

if (vItPOI == attributes.at(i).end()) continue; 

,并把它改成

if (attributes.at(i).find("POI") == attributes.at(i).end()) continue; 

所以功能应该保持不变。我很幸运,因为变量只用于获取形状属性的字符串值,除了几个ifs我不必做太大改变。