[GIS] Writing python plugin: How terminate plugin from script without closing QGIS

pythonqgis

I'm writing a QGIS conversion plugin in python to be able to create Obstacle-files for a model from shapefiles.

What I want to do now is just to close the plugin cleanly. This means, to close the GUI, to delete the variables and so on. I tried to use sys.exit(), but it also closes QGIS.

How do I only close the plugin?

Best Answer

If you are using a subclass of QWidget (e.g. a QDialog or QMainWindow) you can simply call the widget's close or hide method. If you want to free memory used by your variables you can delete them with del or set them to None and they will be garbage collected.