#include "mywidget.h"
#include "ui_mywidget.h"
#include <QPushButton>
MyWidget::MyWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MyWidget)
{
ui->setupUi(this);
//对于父窗口 坐标系统相对于屏幕,原点在左上角
//x 向右递增 y 向下递增
move(0,0);
QPushButton *b1 = new QPushButton(this);
b1->move(100,100);
b1->resize(150,100);
b1->setText("@_@");
QPushButton *b2 = new QPushButton(b1);
b2->move(50,50);
b2->setText("^_^");
//①指定父对象后②直接或间接继承父对象的条件下 子对象如果是动态分配内存的 不需要自己手动释放
}
MyWidget::~MyWidget()
{
delete ui;
}
吃饭睡觉学QT(5)- 坐标系统,内存回收机制
最新推荐文章于 2022-07-06 09:53:00 发布