ProgramAfter writing too much, you will find that almost all the QT class constructor will have a parent parameter. This parameter is usually qobject * or qwidget *
Type. In many cases, it has an initial value of 0, so even if you don't copy it, there is no problem. Therefore, if you are a little lazy, you will unconsciously ignore this parameter. So, this parameter
What is it?
In fact, this parameter is very useful. Like its name, this parameter specifies the parent component of the component. For a dialog box, the dialog box is generally not used as a top-level container.
Generally, there is no dialog box. How can I specify that this dialog box is not a top-level container? Isn't the component with a parent component a top-level container? Therefore, as long as you specify the parent attribute of the dialog box, the task
It will not appear in the column. Of course, if you do not specify it, this dialog box will become a top-level container, and the taskbar will leave a location for it-with this feature, you can implement a special dialog box that can be displayed on the taskbar
For example, the "about" dialog box appears.
In addition, the parent parameter specifies the parent component of the component. In this way, when the parent component is deleted, QT can ensure that all child components-that is
The parent Pointer Points to all components of this component -- it will be deleted correctly. This is why QT can help us manage part of the memory. Qt traverses the parent
To prevent this part of Memory leakage. Therefore, do not forget to set this parent attribute if necessary. Of course, if you do not declare this property, the operating system will reclaim it when the entire program is closed.
Memory-so the memory leakage we call generally refers to the internal memory of the application we write ourselves, without affecting the entire operating system-Of course, if your implementation is too bad, the operating system cannot handle Automatic shutdown.
Your program's :-)