#include "mainwindow.h" #include "./ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); hello(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::hello() { auto btn = new QPushButton(this); btn->setText("Exit"); btn->connect(btn, &QPushButton::clicked, this, &MainWindow::Exit); } void MainWindow::Exit() { exit(0); }