Results 1 to 16 of 16

Thread: Acquire data from database & Plot it to a graph

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Question Acquire data from database & Plot it to a graph

    hi all,

    i am a newbie to this world of QT, and sq lite. I managed to do every thing correctly & tried with some examples also... but got stuck with this problem....

    firstly i connected my form with my database ie. sqlite ...i am able to get data and view it in my required format... but now instead of representing data in reports or in some other format i need to plot data in the forms of graphs just like in the qwt example cpuplot.pro.

    Qt Code:
    1. m_time++;
    2. memmove(m_y, &m_y[1], 99 * sizeof(double));
    3. m_y[99] = 10 * sin((double)m_time / 360 * 3.1415 * 10) + rand() % 80 - 50;
    4.  
    5. for (int i = 0; i < 100; i++)
    6. m_x[i]++;
    7. if (!m_curve)
    8. {
    9. m_curve = new QwtPlotCurve();
    10. m_curve->setPen(QPen(Qt::red));
    11. m_curve->setData(m_x, m_y, 100);
    12. m_curve->attach(myPlot);
    13. }
    14. m_curve->setData(m_x, m_y,100);
    15. myPlot->setAxisScale(QwtPlot::xBottom, m_time, m_time +100); // auto replots
    To copy to clipboard, switch view to plain text mode 

    from the above code i am getting a perfect graph plot by generating random values in the form of a sine wave...

    insted of using this formula
    10 * sin((double)m_time / 360 * 3.1415 * 10) + rand() % 80 - 50;
    i need to get data from database and plot it...

    so can any one help me out..
    Please view the image attached below to get a clear picture...

    thnx in advance.....
    c ya...
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.