-1

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;
Mike
  • 563
  • 5
  • 15
  • 32

2 Answers2

1

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)
//                      ^^^^^^
Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62
0

In the expression

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

you try to subtract a float from a QVector.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621