#include "widget2.h" Widget2::Widget2(QWidget *parent) : QWidget(parent) { setWindowTitle("题目2"); setFixedSize(800,600); btn = new QPushButton("按钮",this); btn->setFixedSize(200,100); btn->move(10,10); label = new QLabel("占位",this); label->resize(300,200); label->move(10,130); connect(btn,&QPushButton::clicked,[&]()->void{ label->setText("1+1=2"); }); }