In Qt Designed, right click on the button and select Go to Slot...

Select clicked(), and click OK.

The method of MainWindow::on_pushButton_clicked() will be generated automatically.
Insert the code:
void MainWindow::on_pushButton_clicked()
{
QMessageBox msgBox;
msgBox.setText("It's going to Quit!");
msgBox.exec();
}

Save, Build and Run the application.
