Quote Originally Posted by Harvey West View Post
I wondered why that was coded in the original QT examples.
That's because the TreeModel created in main(). QApplication::exec() in the end of the main() will be blocking as long as the application runs. The model will be automatically destructed as soon as the application exits and the tree model gets out of scope. Thanks to the fact that QApplication::exec() blocks as long as the application runs, it's safe to allocate objects on the stack in main().

It wouldn't make any difference in the behaviour if the model was allocated on the heap and was made as a child of the view. Then it would simply be deleted by the view (when it gets out of scope as it's allocated on the stack).