PyQt5 QSpinBox – Deleting it according to user
In this article we will see how we can delete the spin box when user command, while designing an application it could potentially consume a lot of space/memory if care is not taken when closing widgets. The QObject-based classes are designed to be (optionally) linked together in a hierarchy. When a top-level object is deleted, Qt will automatically delete all its child objects as well.
In order to explicitly delete the reference of the spin box we use
Syntax : spin_box.deleteLater()
Argument : It takes no argument
Action performed : It deletes/remove the reference of the spin box from the memory.
Implementation steps :
1. Create a spin box
2. Create a label to show spin box status
3. Create push button
4. Add action to the push button
5. Inside the action delete the reference of the spin box and update the text of label
Below is the implementation