# How to remove a layer and its legend in a standalone pyqgis application? [closed]

In continuity in my question How to add a legend to a canvas in a standalone PyQGIS application? > In every addition of a new layer in my standalone application, the legend lengthens and becomes overloaded. So I would like to know how to remove one or several layers with his(their) legend(s). Sorry for my english.

## closed as off-topic by PolyGeo♦Mar 16 '18 at 8:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

• I haven't been able to remove layers safely using QgsMapLayerRegistry.instance().removeMapLayer(id). I keep getting segmentation faults when removing/adding layers (like here: osgeo-org.1560.x6.nabble.com/…). Could you confirm it? – Germán Carrillo Apr 14 '15 at 12:59