Results 1 to 3 of 3

Thread: SetSamples Function

  1. #1
    Join Date
    Dec 2017
    Posts
    19
    Thanks
    10
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default SetSamples Function

    Hi everyone,
    I'm beginner in coding.
    May anyone help me how should I use SetSamples() Function?
    :
    Qt Code:
    1. {
    2. ui->setupUi(this);
    3.  
    4. QwtPlot *BPlot = new QwtPlot(this);
    5. setCentralWidget(BPlot);
    6.  
    7. QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
    8. double frequency=10.288;
    9. double amp=10.288;
    10. int count=10;
    11.  
    12. curve1->setSamples(frequency,amp,count);
    13. curve1->attach(BPlot);
    14. BPlot->replot();
    15. }
    16. MainWindow::~MainWindow()
    17. {
    18. delete ui;
    19. }
    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. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,309
    Thanks
    244
    Thanked 678 Times in 668 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    CodeFreak (4th January 2018)

  4. #3
    Join Date
    Dec 2017
    Posts
    19
    Thanks
    10
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: SetSamples Function

    Quote Originally Posted by d_stranz View Post
    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.

Similar Threads

  1. Using QwtPlotSpectroCurve::setSamples with large data
    By raphael.lencrerot in forum Qwt
    Replies: 2
    Last Post: 4th October 2013, 17:35
  2. pass member function as argument int template function
    By bibhukalyana in forum General Programming
    Replies: 1
    Last Post: 12th March 2013, 08:05
  3. Replies: 11
    Last Post: 5th September 2012, 21:47
  4. Replies: 4
    Last Post: 2nd August 2012, 08:42
  5. Replies: 0
    Last Post: 10th March 2010, 09:13

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.