QT 练习 1:QPushButton 使用和练习,附 DEMO
作者:
孙掌门 | 来源:发表于
2019-10-09 19:52 被阅读0次
QT 练习 1:QPushButton 使用和练习,附 DEMO
ui->setupUi(this);
QPushButton *btn = new QPushButton;
// btn->show();
btn->setParent(this);
btn->setText("你好,世界");
QPushButton *btn2 = new QPushButton("孙承秀",this);
this->resize(300,150);
btn2->move(100,100);
btn2->resize(100,100);
// 重置窗口的标题
this->setWindowTitle("hello");
// 固定大小
setFixedSize(600,400);
// 对象树概念
MyButton *mbtn = new MyButton;
mbtn->setText("我的按钮");
mbtn->move(200,200);
// 添加到对象树,会自动释放,从下往上释放,虽然先打印父类但没有真正的释放,子类释放完之后,父类才会释放
mbtn->setParent(this);
// 信号和槽
connect(mbtn,&MyButton::clicked,this,&Widget::close);
本文标题:QT 练习 1:QPushButton 使用和练习,附 DEMO
本文链接:https://www.haomeiwen.com/subject/tambuctx.html
网友评论