hi,
for(int i=q.first();i<q.last();i++)
{
x_list.append(q.value(i));
y_list.append(q.value(i));
m_curve
->setPen
(QPen(Qt
::red));
m_curve->setData(x_list.value(i), y_list.value(i), 100);
m_curve->attach(myPlot);
myPlot->replot();
}
for(int i=q.first();i<q.last();i++)
{
QList <Double> x_list;
x_list.append(q.value(i));
QList <Double> y_list;
y_list.append(q.value(i));
m_curve = new QwtPlotCurve();
m_curve->setPen(QPen(Qt::red));
m_curve->setData(x_list.value(i), y_list.value(i), 100);
m_curve->attach(myPlot);
myPlot->replot();
}
To copy to clipboard, switch view to plain text mode
Actually from the for loop i am explaining
taking a incremental value i and initializing that to the first value present in the query
QSqlQuery q("SELECT xval,yval FROM PlotGraph1");
this is the query which displays the values present in the database..
taking a qlist and x_list which takes the x values present in the database...
assigning the values present in the database to x and y...
here x_list is being appended with the values of xval (first field) present in the database..
QList <double> x_list;
x_list.append(q.value(i));
similarlly
here y_list is being appended with the values of yval (second field) present in the database..
QList <double> y_list;
y_list.append(q.value(i));
Next
m_curve = new QwtPlotCurve();
m_curve->setPen(QPen(Qt::red));
m_curve->setData(x_list.value(i), y_list.value(i), 100);
m_curve->attach(myPlot);
myPlot->replot();
now i am initializing a curve as m_curve
taking red color to plot my curve, i initialized a pen over here..
m_curve->setData(x_list.value(i), y_list.value(i), 100);
this actually takes the values present in the x_list and y_list ..
now
m_curve->attach(myPlot);
myPlot->replot();
the above code will attach my curve to my qwtplot widget ie..(myPlot)
and plots the points based on the values taken above...
i kept this code in draw function and keep on calling @ 1sec rate with the timer....
I think i have explained every thing present in the code....
if i go wrong any where please correct me so that i will not repeat the mistake again...
thanks in advance...
giving or taking, both r the similar form's of getting knowledge...
Bookmarks