Answer the question
In order to leave comments, you need to log in
Qt. Why is it necessary, and why is it not necessary to free memory?
I can't understand how it works in Qt.
Is it necessary to create top-level objects (this) dynamically (after all, the order of creation and destruction can be different and then the stack cannot be used here)? If so, how is it that all lower-level objects release memory automatically? Should delete be used on the top-level object?
Example:
there is a class How to create
a class Widget : public QWidget { };
top-level object
more correctly
?
And how is the release of the entire hierarchy that is inherited from Base? Where is the destructor called to clear the memory? Not in Widget? Or does the MOC create its own part of the code to release?Widget Base;
Widget *Base = new Widget;
delete Base;
If so, what if I create an explicit destructor? Whether it is necessary to release storage for hierarchy now already most?
Answer the question
In order to leave comments, you need to log in
What is the correct way to create a top-level object?:
so Widget Base;
or Widget *Base = new Widget;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question