QCustomPlot Discussion and Comments

How to fully remove a QCPItemStraightLine?Return to overview

Hello all,

I have a plot with a single graph where I am adding a vertical line via a right mouse click.
I create a QCPItemStraightLine via a pointer and the "new" keyword while passing "this" as the parent.
The pointer is also added to a QList collecting all vertical lines added in this way.

When I want to delete one of these vertical lines I am calling removeItem() and removeAt() for the QList. I have seen in the documentation where it says to call removeItem() instead of deleting manually.

The problem is the vertical line continues to be displayed in the graph.
Is there something else I have to do to remove this?
I see the documentation talks about this item being automatically "registered" with the qcustomplot. Maybe I have to do something to "unregister" the item?

Are you calling replot after calling removeItem?

Only other thing I can think of is you maybe create the line twice and only remove one of them?