c++ - 将项目从qt4迁移到qt5时没有匹配的调用函数

标签 c++ qt migration candidate no-match

我正在将一个项目从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");

老实说,我不知道如何更正这些行,使它们与建议的候选函数相匹配。 我希望有人能对这个问题有所了解。 谢谢。

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

最佳答案

我通过转动解决了

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;

所以功能应该保持不变。我很幸运,因为该变量仅用于获取 shape 属性的字符串值,除了一些 ifs 我不需要做太多更改。

关于c++ - 将项目从qt4迁移到qt5时没有匹配的调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23493865/

相关文章:

django - 恢复已删除的 Django 迁移

azure-devops - 如何将测试用例从 Excel 导入到 VSTS/Azure DevOps

c++ - openmp两个连续循环,归约子句问题

c++ - 在给定数组中找到所有唯一的三元组,总和为零,执行时间最短

c++ - 当用户选择一个项目时 QListWidget 移动

c++ - 在 macOS 上从源代码构建 Qt 时出错

php - Laravel 迁移不反射(reflect)当前的数据库架构

c++ - 需要一个命令行解析器来满足我的要求

c++ - 让软件中断在裸机 Beaglebone Black 中工作

c++ - Qt:强制QWebView点击一个网络元素,即使是在窗口上不可见的元素