hello.
I have a source of data that is displayed in real time. the x-axis is current coordinate and it varies randomly (depending on the speed and direction). so for chart on the x-axis I'm using the current number of points, and replace it when displayed on the coordinate in QwtScaleDraw:
// in QwtPlotCurve *pcd I fill data:
for (int i = 0; (i < data.length); i++){
xAlias[i] = i;
x[i] = data_x[i];
y[i] = data_y[i];
}
setSamples(xAlias, y, data.length);
// in QwtScaleDraw I take real value by alias:
QwtText myQwtScaleDraw
::label(double v
) const {
return QString("%1").
arg(pcd
->x
[((int)v
)]);
}
// in main Widget:
myPlot
->setAxisScale
(QwtPlot::xBottom,
0, data.
length,
0);
myPlot->replot();
// in QwtPlotCurve *pcd I fill data:
for (int i = 0; (i < data.length); i++){
xAlias[i] = i;
x[i] = data_x[i];
y[i] = data_y[i];
}
setSamples(xAlias, y, data.length);
// in QwtScaleDraw I take real value by alias:
QwtText myQwtScaleDraw::label(double v) const
{
return QString("%1").arg(pcd->x[((int)v)]);
}
// in main Widget:
myPlot->setAxisScale(QwtPlot::xBottom, 0, data.length, 0);
myPlot->replot();
To copy to clipboard, switch view to plain text mode
but this only works if there is a change of xAlias[]. if I change the array x referenced by the xAlias, repainting occurs.
how to make a graph to be redrawn manually?
myPlot->repaint(), myPlot->update(), myPlot->axisWidget( QwtPlot::xBottom )->update(); does not work too.
Thanks in advance.
Bookmarks