# Thread: SetSamples Function

1. Novice
Join Date
Dec 2017
Posts
19
Thanks
10
Qt products
Platforms

## SetSamples Function

Hi everyone,
I'm beginner in coding.
May anyone help me how should I use SetSamples() Function?
:
Qt Code:
`{    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;}`
To copy to clipboard, switch view to plain text mode
no matching function for call to 'QwtPlotCurve::setSamples(double&, double&, int&)'
curve1->setSamples(frequency,amp,count);

2. ## Re: SetSamples Function

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.

3. ## The following user says thank you to d_stranz for this useful post:

CodeFreak (4th January 2018)

4. Novice
Join Date
Dec 2017
Posts
19
Thanks
10
Qt products
Platforms

## Re: SetSamples Function

Originally Posted by d_stranz
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?
Last edited by CodeFreak; 4th January 2018 at 13:02.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.