我收到以下错误:
错误:'operator-'不匹配(操作数类型为'QVector'和'const float')
尝试时:
dist.push_back(qPow((clusterMeanCoordinate[t].at(i) - hash_notClustered[t].at(point)), 2) + qPow((clusterMeanCoordinate[w] - hash_notClustered[w].at(point)), 2));
请注意:
QHash<int, QVector<float> > clusterMeanCoordinate;
QHash<int, QVector<float> > hash_notClustered;
QVector<float> dist;
答案 0 :(得分:1)
您的错误在这里:
dist.push_back(
qPow( (clusterMeanCoordinate[t].at(i) - hash_notClustered[t].at(point) ), 2) +
qPow( (clusterMeanCoordinate[w] - hash_notClustered[w].at(point)), 2));
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
您要在QVector
和const float
之间进行减法:
clusterMeanCoordinate[w] - hash_notClustered[w].at(point)
// QVector - const float
您可以通过以下方式解决问题:
clusterMeanCoordinate[w].at(i) - hash_notClustered[w].at(point)
// ^^^^^^
答案 1 :(得分:0)
在表达式
中clusterMeanCoordinate[w] - hash_notClustered[w].at(point)
您尝试从float
中减去QVector
。