The problem here is :
I have some existing graphs in channelGraphList and I want to add one graph per rect (new rect). The idea behind this is that I want to switch between a single rect containing multiple graphs, to a plot containing multiple rects with one graph in each (and vice-versa).

But it seems there are no fonctions to setGraph in QCPAxisRect or in QCustomPlot.

void MultiRectChannelPlot::init(QList<QCPGraph*> channelGraphList)

     // let's start from scratch and remove the default axis rect

    // create a sub layout that we'll place in first row:
    QCPLayoutGrid *subLayout = new QCPLayoutGrid();
    plotLayout()->addElement(0, 0, subLayout);

    for (int i = 0; i < channelGraphList.size(); i++)
        QCPAxisRect* r = new QCPAxisRect(this);


// I  don't want to use addGraph here, since it will create a new graph. I want to use the already created graphs in channelGraphList instead.
//        QCPGraph* g = addGraph(r->axis(QCPAxis::atBottom),
//                               r->axis(QCPAxis::atLeft));

       subLayout->addElement(i,  0,  r); 

How could this be achieved without recreating new QCPGraphs.