27 lines
550 B
C++
27 lines
550 B
C++
#include "widget1.h"
|
|
|
|
Widget1::Widget1(QWidget *parent) : QWidget(parent)
|
|
{
|
|
btn = new QPushButton("Ok",this);
|
|
close_btn = new QPushButton("退出",this);
|
|
label = new QLabel("结果: ",this);
|
|
|
|
btn->resize(100,50);
|
|
btn->move(10,10);
|
|
|
|
close_btn->resize(100,50);
|
|
close_btn->move(120,10);
|
|
|
|
label->resize(200,50);
|
|
label->move(10,70);
|
|
|
|
connect(btn,&QPushButton::pressed,[&](){
|
|
label->setText("结果: 1+1 = 2");
|
|
});
|
|
|
|
connect(close_btn,&QPushButton::pressed,[&](){
|
|
this->close();
|
|
});
|
|
|
|
}
|