Hi
I´m trying to replot the graph with a new value (witch I typed in) of stepw after klicking a button
(pushButton_2) but no matter what I try it won´t work.
Is there anyone who can tell me what I have to write between the green lines ?
#include "QPstuff.h" using namespace std; QPstuff::QPstuff() { size=20; stepw=2.0; count=0; }; QPstuff::~QPstuff() {}; int QPstuff::getsize() { return size; }; double QPstuff::getstepw() { return stepw; }; void QPstuff::setsize(int a) { size=a; }; void QPstuff::setstepw(double a) { stepw=a; }; double QPstuff::getcount() { return count; }; void QPstuff::countup() { count=count+stepw; }; void QPstuff::setcount(double a) { count=a; };
#include "dialog.h" #include "ui_dialog.h" #include "QPstuff.h" QPstuff stuff; Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); QVector<double>x(stuff.getsize()),y(stuff.getsize()); for(int i=0;i<stuff.getsize();i++) { x[i]=stuff.getcount(); y[i]=sin(stuff.getcount()); stuff.countup(); }; ui->plot->addGraph(); ui->plot->graph(0)->setData(x,y); ui->plot->xAxis->setRange(-5,10); ui->plot->yAxis->setRange(-5,10); } Dialog::~Dialog() { delete ui; } void Dialog::on_pushButton_clicked() { bool ok1; double x1=ui->textEdit->toPlainText().toDouble(&ok1); stuff.setstepw(x1); ui->lcdNumber->display(stuff.getstepw()); } void Dialog::on_pushButton_2_clicked() { stuff.setcount(0.0); //---------------------------------------- //---------------------------------------- }