Try removing the keyword this before customPlot
void MainWindow::on_pushButtonSwap_clicked()
{
// generate some data:
QVector<double> x(101), y(101);
for (int i=0; i<101; ++i) {
x[i] = i/50.0 - 1; // x goes from -1 to 1
y[i] = x[i]*x[i]; // let's plot a quadratic function
}
customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->xAxis->setLabel("x");
customPlot->yAxis->setLabel("y");
customPlot->xAxis->setRange(-1, 1);
customPlot->yAxis->setRange(0, 1);
customPlot->replot();
}
void MainWindow::on_pushButtonSwap_clicked()
{
// generate some data:
QVector<double> x(101), y(101);
for (int i=0; i<101; ++i) {
x[i] = i/50.0 - 1; // x goes from -1 to 1
y[i] = x[i]*x[i]; // let's plot a quadratic function
}
customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->xAxis->setLabel("x");
customPlot->yAxis->setLabel("y");
customPlot->xAxis->setRange(-1, 1);
customPlot->yAxis->setRange(0, 1);
customPlot->replot();
}
To copy to clipboard, switch view to plain text mode
if customPlot is defined in one of the header files, if not you need to declare an object of type QCusomPlot named customPlot in MainWindow class.
this->customPlot
this->customPlot
To copy to clipboard, switch view to plain text mode
means that the class MainWindow has a member named customPlot, and in this case it does not exists.
Bookmarks