Qt - conversion qreal to double

12,892

QPointF is a class (not a struct) and QPointF::x() is a method, not a public member. Try:

double px = pt.x();
Share:
12,892
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm using Ubuntu 11.10, Qt 4, Qwt 6.0.1

    the problem is that in general everything works, examples from Qwt compile without ANY problems, but when I try to convert from QPointF.x to double I get error. The funnies thing is that (on x86) qreal is supposed to be redefinition of double...

    here is what doesn't work (

    QPointF pt;
    pt.setX(1.0);
    pt.setY(2.0);
    double px=pt.x;
    

    the compiler returns error:

    error: argument of type ‘qreal (QPointF::)()const {aka double (QPointF::)()const}’ does not match ‘double’
    

    Am I doing something stupid?

    In short:

    I need to convert it to use in class inheriting from QwtSeriesData to make custom interpolation between points (in this case it's not gonna be simple linear interpolation). For that I need method

    double y(double x) const
    

    which will return value of function of given x

    when I simplified it to use QwtSeriesData it compiles. For this to work it was just necessary to implement

    QPointF sample(size_t i) const
    size_t size() const
    

    but as I said, I need custom interpolation, so seems that implementing interface inheriting from QwtSyntheticPointData is the best option.