PDA

View Full Version : SetSamples Function



CodeFreak
3rd January 2018, 17:57
Hi everyone,
I'm beginner in coding.
May anyone help me how should I use SetSamples() Function?
:

{
ui->setupUi(this);

QwtPlot *BPlot = new QwtPlot(this);
setCentralWidget(BPlot);

QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
double frequency=10.288;
double amp=10.288;
int count=10;

curve1->setSamples(frequency,amp,count);
curve1->attach(BPlot);
BPlot->replot();
}
MainWindow::~MainWindow()
{
delete ui;
}

no matching function for call to 'QwtPlotCurve::setSamples(double&, double&, int&)'
curve1->setSamples(frequency,amp,count);

d_stranz
4th January 2018, 00:07
There is no setSamples() method for QwtPlotCurve that takes a double, double, and int as arguments. That's what the compiler is telling you.

QwtPlotCurve has no idea of the shape of the curve - it doesn't compute it, you have to compute it yourself and give the point values to QwtPlotCurve either as arrays (the setSamples version that takes double * xData, double * yData, int size as arguments) or as vectors (the setSamples version that takes QVector<double> & xData, QVector<double> & yData).

The code in the curvdemo1 example in your Qwt distribution shows one way of doing this.

CodeFreak
4th January 2018, 09:25
There is no setSamples() method for QwtPlotCurve that takes a double, double, and int as arguments. That's what the compiler is telling you.

QwtPlotCurve has no idea of the shape of the curve - it doesn't compute it, you have to compute it yourself and give the point values to QwtPlotCurve either as arrays (the setSamples version that takes double * xData, double * yData, int size as arguments) or as vectors (the setSamples version that takes QVector<double> & xData, QVector<double> & yData).

The code in the curvdemo1 example in your Qwt distribution shows one way of doing this.

Thanks a lot for your reply 🖤🖤🖤
I want to plot real time data in the form like CPUPLOT example which X axis varies according to time changes and the curve is shifted to the left.
The CPUPLOT example has been decorated by some functions that make it hard a bit for beginners.
May I ask you let me know that which functions I should use or any further information that is critical?