QCustomPlot Discussion and Comments

My QCustomPlot in my code is not workingReturn to overview

mainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "qcustomplot.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    void makePlot();
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QLineEdit>
#include<QToolButton>
#include "qcustomplot.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    MainWindow::makePlot();

}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::makePlot()
{
    double h=1/(100);
    QVector<double> x(102),y(102);
    x[0]=0;
    y[0]=1;
    for(int n=1;n<100;n++)
    {
        x[n]=n/50;
        y[n]=x[n]*y[n];
    }


    ui->customPlot->addGraph();
    ui->customPlot->graph(0)->setData(x,y);
    ui->customPlot->xAxis->setLabel("x");
    ui->customPlot->yAxis->setLabel("y");
    ui->customPlot->xAxis->setRange(0,1);
    ui->customPlot->yAxis->setRange(0,1);
    ui->customPlot->replot();






}

You are a beginer?

Change MainWindow::makePlot() to makePlot()

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
makePlot();

}

You did not bind your ui to your class