按钮
#include "mywidget.h"
#include <qpushbutton.h>
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
// first button
QPushButton *btn = new QPushButton;
// btn->show();
btn->setParent(this);
btn->setText("第一个按钮");
// second button, same as first
QPushButton *btn2 = new QPushButton("second button", this);
// reset windows size
resize(800, 600);
// move button
btn2->move(100, 100);
// set window title
setWindowTitle("First Windows");
// set fixed size
setFixedSize(800, 400);
}
MyWidget::~MyWidget()
{
}
对象树
QObject
的子类会自动析构