Download

Do I have to manually reset all widget variables upon removing from parent?

Hello all, So when removing a menu widget from parent it keeps all the variable values stored in memory, correct? Is there a way to reset these values without manually going through and resetting each one individually? Is there a way I can just destroy the widget so that when I create it again all the variables reset to their defaults?
Thanks for your help,
Cheers.

Well, you’re right that removing a widget from its parent need not necessarily destroy it. It will remain so as long as there are references to it. So if you want to make sure that it’s destroyed, clear all references to this widget and then it will get deleted by the Garbage Collector.

Regardless when you create a new widget based on the same class, it will spawn a completely new instance of it with all your default values.

Perfect that sounds like exactly what I need. I’m not at my computer right now but I’ll try it out and see if it works later. Thanks again.