for (int i=0; i<101; ++i) { x[i] = i/50.0 - 1 ; // x goes from -1 to 1 y[i] = 0.5 ; // let's plot a quadratic function } // create graph and assign data to it: ui->widget->addGraph(); ui->widget->graph(0)->setData(x, y); // give the axes some labels: ui->widget->xAxis->setLabel("x"); ui->widget->yAxis->setLabel("y"); // set axes ranges, so we see all data: ui->widget->xAxis->setRange(-1, 1); ui->widget->yAxis->setRange(-1, 1); ui->widget->replot();
x[i] = h*i - dlina ;
x[i] = i/50.0 - 1 ;
x[i] = h*i - dlina
x.resize(i);y.resize(i);