自定义信号与槽:
1.在dialog的头文件添加
public slots:
void showChildDialog();
2.右键代码,找到"Refactor",在cpp生成showChildDialog()函数
void Dialog::showChildDialog()
{
QDialog * dialog = new QDialog();
dialog->show();
}
3.在构造函数内添加connect语句
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog)
{
ui->setupUi(this);
connect(ui->showChildButton,&QPushButton::clicked,this,
&Dialog::showChildDialog);
}