Python qt: workflow notes
From wikinotes
delete/handle delete
Deleting layouts does not always work well, you'll have much more predictable results if you put your layout into an empty QWidget, then delete the QWidget.
widget.deleteLater() # delete a widget (when the current scope exits) widget.destroyed.connect(some_function) # run when widget is deleted class MyWidget(QtWidgets.QWidget): def closeEvent(self, event): # do something