Question

I get the following error:

error: no match for 'operator-' (operand types are 'QVector' and 'const float')

when trying to do:

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

Note that:

QHash<int, QVector<float> > clusterMeanCoordinate;
QHash<int, QVector<float> > hash_notClustered;
QVector<float> dist;
Was it helpful?

Solution

Your error is here :

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

Here you are making a substraction between a QVector and a const float :

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

You can solve it by doing :

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

OTHER TIPS

In the expression

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

you try to subtract a float from a QVector.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top