[SOLVED] [Qwt and a DB] How to plot data coming from a DB with Qwt



  • Hello Qt devs!

    I have written this so far, but the code won't compile:

    @
    xAxisTime = new QSqlQuery;
    xAxisTime->prepare("SELECT date(qa."QA_Timestamp") FROM "v_TestResults"");
    xAxisTime->exec();
    xAxisTime->next();

    // Preperation of general query to fetch test results
    yAxis = new QSqlQuery;
    yAxis->prepare("SELECT \"OUT_Output\" FROM \"v_TestResults\" WHERE \"OUT_IndexResultat\" = :idtest, \"OUT_Minor\" = :row, \"OUT_Minor\" = :col");
    yAxis->bindValue(":idtest", 20);
    yAxis->bindValue(":row", 1);
    yAxis->bindValue(":col", 1);
    yAxis->exec();
    yAxis->next();
    
    plotDsi0 = new QwtPlotCurve(trUtf8("DSI0"));
    plotDsi0->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);
    plotDsi0->setData(xAxisTime->value(1).toDouble(), yAxis->value(1).toDouble(),
                      yAxis->size());
    
    plotDsi0->attach(CKV2_qwtPlot);
    

    @

    The compiler complains: that

    @
    there is no matching function call to 'QwtPlotCurve::setData(double, double, int)'
    @

    However, there is a candidate that is:

    @
    QwtPlotcurve:: setData(const double*, const double*, int)
    @

    I guess I could use vectors, but I'm not familiar with them, yet. Is there another way to proceed?

    Thanks for your tips!



  • you should pass pointers to your function.
    @
    double x = xAxisTime->value(1).toDouble();
    double y = yAxis->value(1).toDouble();
    plotDsi0->setData(&x, &y, yAxis->size());
    @

    EDIT:

    Primitives have ctors, so this will work too:
    @
    plotDsi0->setData(new double(xAxisTime->value(1).toDouble()), new double(yAxis->value(1).toDouble()),
    yAxis->size());
    @



  • Pointers to the QSqlQuery? But that won't return the actual record stored in the query. Plus, it won't return a double. I'm not sure I understand what you mean.



  • Thanks @soroush. It worked perfectly.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.