#include "widget5.h" Widget5::Widget5(QWidget *parent) : QWidget(parent) { setWindowTitle("让Widget6消失"); setFixedSize(400,600); move(400,300); w6 = new Widget6; btn = new QPushButton("显示Widget6按钮",this); btn->setFixedSize(200,100); btn->move(10,10); connect(btn,&QPushButton::clicked,[&]()->void{ this->setWindowTitle("让Widget6消失"); w6->show(); }); connect(w6,&Widget6::stealth,[&]()->void{ this->setWindowTitle("Winget6消失了"); w6->close(); }); }