// 父子关系--能够比较其余语言或框架中的容器子对象等

#include <QApplication>

#include <QFont>

#include <QPushButton>

#include <QWidget>
int main(
int argc,
char *argv[])

{

QApplication app(argc, argv);
//建立应用程序对象

QWidget window;
//建立窗体对象

window.resize(200, 120);
//设置大小

QPushButton quit(
"Quit", &window);
//建立按钮,以上面的window对象做为父容器

quit.setFont(QFont(
"Times", 18, QFont::Bold));

quit.setGeometry(10, 40, 180, 40);
//设置几何位置及尺寸,这里坐标(10,40)宽高(180,40)

QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));

window.show();
//显示窗体
return app.exec();

}