QCustomPlot Discussion and Comments

How to properly remove layout element? Return to overview

So I add a QCPTextElement as a title to my plot like this:

        QCPTextElement *title = new QCPTextElement(customPlot,"Title");
        customPlot->plotLayout()->insertRow(0);
        customPlot->plotLayout()->addElement(0,0, title);

I'd like to create a button to let user remove the entire title (to make the plot area larger), I tried this:

customPlot->plotLayout()->remove(customPlot->plotLayout()->element(0,0));

However this doesn't seem to remove the layout row and it actually make my plot half of the plotting area. What am I missing and how I can properly remove layout element? Thanks.

Have a look at the documentation of the remove method. Let me know if anything is still unclear!

simplify() is what I'm missing. Thanks a lot!