创建QObject时,我们会传递一个QObject指针作为它的父对象,此时 ,该QObject将会自动添加到它的父对象的children()列表中。Qt为了防止内存泄漏,我们创建的QObject对象如果不添加到对象树中,就会被delete。
当这个对象析构时,所有子对象都会被释放(递归式的)
添加新文件
自定义控件时,可选择Base Class。这样新建文件,Qt会自动在Qmake中添加,放止编译出错。
使用QDebug
#include <QDebug>
...
qDebug() << 1;
...
文档:
qDebug(const char *message, ...)
Calls the message handler with the debug message message. If no message handler has been installed, the message is printed to stderr. Under Windows the message is sent to the console, if it is a console application; otherwise, it is sent to the debugger. On QNX, the message is sent to slogger2. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.
If you pass the function a format string and a list of arguments, it works in similar way to the C printf() fu