2013-08-27 49 views
-1

我收到以下错误:问题与操作数类型

error: no match for 'operator-' (operand types are 'QVector' and '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; 

回答

1

你的错误是在这里:做

clusterMeanCoordinate[w] - hash_notClustered[w].at(point) 
// QVector     - const float 

你可以解决它:

clusterMeanCoordinate[w].at(i) - hash_notClustered[w].at(point) 
//      ^^^^^^ 

dist.push_back(
    qPow((clusterMeanCoordinate[t].at(i) - hash_notClustered[t].at(point)), 2) + 
    qPow((clusterMeanCoordinate[w] - hash_notClustered[w].at(point)), 2)); 
//   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

在这里你是一个QVectorconst float之间的减法

0

在表达

clusterMeanCoordinate[w] - hash_notClustered[w].at(point) 

您尝试从QVector减去float