Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MainWindow::on_pushButton_clicked()
- {
- double a,b,c;
- QCustomPlot * thisGraph = ui->customPlot;
- a = ui->lineEdit->text().toDouble();
- b = ui->lineEdit_2->text().toDouble();
- c = ui->lineEdit_3->text().toDouble();
- QVector<double> x(20);QVector<double> y(20);
- QString str, strs;
- double x0 = -b/(2*a);
- double y0 = a*pow(x0, 2.0) + a*x0 + b;
- double xMax = x0+10;
- double xMin = x0-9;
- int i = 0;
- for (double j = xMin; i<x.size(); i++)
- {
- x[i] = j;
- j++;
- }
- std::transform(std::begin(x),std::end(x),std::begin(y),
- [&](double &x){
- return a*pow(x, 2.0) + b*x + c;
- });
- ui->plainTextEdit->setPlainText(str);
- ui->plainTextEdit->setPlainText(strs);
- thisGraph->graph(0)->setData(x,y);
- thisGraph->rescaleAxes(true);
- thisGraph->replot();
- }
Advertisement
Add Comment
Please, Sign In to add comment