#include "widget4.h" Widget4::Widget4(QWidget *parent) : QWidget(parent) { setWindowTitle("题目4"); setFixedSize(800,600); btn = new QPushButton("按钮",this); btn->setFixedSize(200,100); btn->move(10,10); edit1 = new QLineEdit(this); edit1->move(10,120); edit2 = new QLineEdit(this); edit2->move(10,160); label = new QLabel("占位",this); label->move(300,140); connect(btn,&QPushButton::clicked,[&]()->void{ QString str1 = edit1->text(); QString str2 = edit2->text(); int res_num = str1.toInt()+str2.toInt(); label->setNum(res_num); }); }