QCustomPlot Discussion and Comments

Changing the plot with the sign = ?Return to overview


I have a simple question and I'm sorry if it is silly, I'm a beginner in C++ and QCustomPlot.

Is it possible to change the graph of one plot with the graph of an other one by simply using the sign = ?

For exemple, I put one plot in a layer, (let say plot1) and instead of clearing the plot1 and doing addgraph etc, I would like to change plot1 just by doing plot1 = plot2.

Thank you,

if you set the data pointer of the graph1 to equal the data pointer of graph2, then graph1 will show the same data as graph2.

you would still need to call replot obviously and probably rescale Axis as well.

The single issue with this is that obviously since the pointers are equal, any changes you make to the data in graph1 will now also affect graph2.

Also if you do this, you need to make sure that you change the pointer to something else before removing the graph or you will cause a segmentation fault when it deletes the graph data (and also subsequently the data that graph2 is pointing to as well).

Hi Ian,

Thank you for your reply.

I have a second problem, when I add too much graph to my plot (around 6), my program crashes when I change the size of the window and I get this error :
void QCPLayer::drawToPaintBuffer() paint buffer returned inactive painter
QPainter::begin: Paint device returned engine == 0, type: 2

Do someone know why ?