2013-08-27 50 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