Try using "tab->deleteLater()" instead of "delete tab". This defers actual deletion until the next time the event loop runs, which allows Qt to remove the widget and clean up.
Setting "tab = NULL" in the next line really does nothing except to set the value of your local variable that contains the pointer to NULL. It is no different from having an "int" local variable and setting its value to something. As soon as the method exits, the stack is cleaned up and all those local variables go away.
Bookmarks