Guest User

Untitled

a guest
Mar 16th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. void MainWindow::on_pushButton_clicked()
  2. {
  3.     double a,b,c;
  4.     QCustomPlot * thisGraph = ui->customPlot;
  5.     a = ui->lineEdit->text().toDouble();
  6.     b = ui->lineEdit_2->text().toDouble();
  7.     c = ui->lineEdit_3->text().toDouble();
  8.     QVector<double> x(20);QVector<double> y(20);
  9.     QString str, strs;
  10.     double x0 = -b/(2*a);
  11.     double y0 = a*pow(x0, 2.0) + a*x0 + b;
  12.     double xMax = x0+10;
  13.     double xMin = x0-9;
  14.     int i = 0;
  15.     for (double j = xMin; i<x.size(); i++)
  16.     {
  17.         x[i] = j;
  18.         j++;
  19.     }
  20.     std::transform(std::begin(x),std::end(x),std::begin(y),
  21.     [&](double &x){
  22.         return a*pow(x, 2.0) + b*x + c;
  23.     });
  24.     ui->plainTextEdit->setPlainText(str);
  25.     ui->plainTextEdit->setPlainText(strs);
  26.     thisGraph->graph(0)->setData(x,y);
  27.     thisGraph->rescaleAxes(true);
  28.     thisGraph->replot();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment