Consider refreshing your knowledge about memory management with pointers, shared pointers, scope, and the concept of ownership in C++.
You have a local variable newCurve, which points to an object that is memory-managed by QCustomPlot (it "lives inside" QCP).
How would QCP (or any class that you pass ownership for that matter), access that local pointer variable of yours and set it to nullptr?
The simple solution: Do not delete newCurve. You are by contract of ownership not allowed to do that.
Otherwise: use QPointer to track ownership (read its documentation in Qt!). QPointer is special in that it uses the QObject system to detect of the object was destroyed somewhere else in the code (like in removePlottable), and then sets itself to nullptr.