Qt Labs Forum » Graphics View

How to plot graph from database ???

(1 post)
  • Started 5 months ago by crazycoder

  1. crazycoder
    crazycoder
    Member

    Hi all,
    I have been trying to develop an application which need to plot graph from values present in the database..
    This is the code which i used to generate graph from the values from the database...

    [code]

    void test_plotdb::draw()
    {
    m_sqlModel = new QSqlQueryModel(this);
    QSqlQuery q("SELECT xval,yval FROM data_table1");
    if (q.exec())
    {
    for(int i=q.first();i<q.last();i++)
    {
    *s_x=q.value(0).toDouble();
    *s_y=q.value(1).toDouble();
    m_curve = new QwtPlotCurve();
    m_curve->setPen(QPen(Qt::red));
    m_curve->setData((const double*)s_x, (const double*)s_y, 100);
    m_curve->attach(myPlot);
    myPlot->replot();
    }
    }
    else
    {
    QMessageBox::critical(this, "Failure", "Query failure");
    }
    }

    [/code]

    i have cleared all the errors but i couldnt get any output(I mean i need to get output in the form of graph representing the values from the database..)

    can any one solve my problem please....

    thank in advance...

    Posted: 5 months #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.