Search code examples
c++qtqwt

Probléme with syntax of closestPoint qwt


thank you for helping me use the method of closestPoint qwt to recover the value of y corresponds to a value x. I put that but still the problem of syntax ?

error: invalid type '<unresolved overloaded function types> [int]' for array subscript 

Code:      

Curve-> closestPoint (pos [0], NULL); 

Solution

  • You get this error because you call some method, but you use [] instead of ()so you should use:

    Curve->closestPoint(pos(), NULL); 
    

    As doc said closestPoint requires QPoint

    int QwtPlotCurve::closestPoint (const QPoint & pos, double * dist = NULL ) const
    

    For example:

    Curve->closestPoint(QPoint(1,1),NULL);